allow to set custom serial speed on Linux#80534
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-io Issue Details
fixes #80288
|
|
@wfurt the MUSL legs are failing due to missing |
|
I'll take a look. If it is only because of missing Ioctl name it would be easy to fix. |
| return 0; | ||
| } | ||
| " | ||
| HAVE_TERMIOS2) |
There was a problem hiding this comment.
do we know which rids will not have this defined?
There was a problem hiding this comment.
Actually, we also need to update the eng/native/tryrun.cmake for cross build to get this definition. The live detection in configure.cmake is 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.
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.h so I expect it would compile everywhere.
There was a problem hiding this comment.
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
set_cache_value(HAVE_TERMIOS2_EXITCODE 0)There was a problem hiding this comment.
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.
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.
I check FreeBSD headers and there is neither termios2 or TCGETS2. 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.
Since everything else is the same, I'd just make setting this single value conditional based on where it is supported.
eng/native/tryrun.cmake
Outdated
| set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0) | ||
| set_cache_value(HAVE_TERMIOS2_EXITCODE 1) | ||
| else() | ||
| set_cache_value(HAVE_TERMIOS2_EXITCODE 0) |
There was a problem hiding this comment.
nit: the current style is to add the "default" before the conditional block (line 103) and override the platform specific values where needed. This way we won't be needing this else() block.
* allow to set custom serial speed on Linux * fix compilation on alpine * add entries for cross build
asm/termbits.hconflicts with standardtermios.hso I put the new code to separate file instead of usual#if XXXI don't have enough HW to test actual transfer but at least I'm able to open port with custom speed.
fixes #80288