-
Notifications
You must be signed in to change notification settings - Fork 5.4k
allow to set custom serial speed on Linux #80534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| #include "pal_types.h" | ||
| #include "pal_utilities.h" | ||
| #include <asm/termbits.h> | ||
| #include <asm/ioctls.h> | ||
| #include <sys/ioctl.h> | ||
|
|
||
| int SystemIoPortsNative_Termios2SetSpeed(int fd, int speed) | ||
| { | ||
| struct termios2 tio2; | ||
| if (ioctl(fd, TCGETS2, &tio2) < 0) | ||
| { | ||
| return -1; | ||
| } | ||
|
|
||
| tio2.c_cflag &= ~(CBAUD | CBAUDEX | ((CBAUD | CBAUDEX) << IBSHIFT)); | ||
| tio2.c_cflag |= BOTHER | (BOTHER << IBSHIFT); | ||
| tio2.c_ospeed = speed; | ||
| tio2.c_ispeed = speed; | ||
|
|
||
| if (ioctl(fd, TCSETS2, &tio2) < 0) | ||
| { | ||
| return -1; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we know which rids will not have this defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we also need to update the eng/native/tryrun.cmake for cross build to get this definition. The live detection in
configure.cmakeis only for non-cross builds. So we need to get the result of this check on all our cross target platforms (by running the build is running natively there) and update the tryrun.cmake accordingly in this PR.@krwq that should give an answer to your question then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to https://man7.org/linux/man-pages/man2/ioctl_tty.2.html this was added in 2.6.20 Kernel e.g. it should be available in all Linux versions we support. (and is Linux specific) I saw note that it may not work on architectures but I don't know any details. The definition lives in
asm-generic/termbits.hso I expect it would compile everywhere.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then we can just add it to the
eng/native/tryrun.cmake. Please note that in that file, you need to set the HAVE_XXX_EXITCODE, not HAVE_XXX and the exit code is 0 for success.In other words, you'll need to add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we ever use it for OSes other than Linux? (Like FreeBSD ARM64)? I was looking for section with plain LINUX but aside from ALPINE I did not find good fit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The section that is used for linux starts here:
runtime/eng/native/tryrun.cmake
Line 74 in 4cf8c07
It is used for all cross builds, that means including FreeBSD. Since the section for Linux is shared with FreeBSD, Illumos and Tizen, we need to know the value for those OSes. It seems that it would be as easy as cross building the repo for those three OSes with your change and the tryrun.cmake modified. If it was not supported, the build would fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I check FreeBSD headers and there is neither
termios2orTCGETS2. I suspect others would be the same.Instead of setting negative value for all the other OSes, would it make sense to create new branch for Linux only?
And if do we already have some variable that we can use (CMAKE_SYSTEM_NAME, CLR_CMAKE_TARGET_OS, ..?) or would we need to invent something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since everything else is the same, I'd just make setting this single value conditional based on where it is supported.