-
Notifications
You must be signed in to change notification settings - Fork 171
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
Overhaul the termios
API.
#615
Conversation
6fdab45
to
e018796
Compare
5d54930
to
db04499
Compare
db04499
to
351e586
Compare
I've now rebased and updated this. And I've also added a major change: This now encapsulates the This is a little higher-level than rustix typically aims for, but it doesn't incur extra syscalls or even extra |
536fc0c
to
04776f6
Compare
9cc626d
to
eabb9b6
Compare
@SUPERCILEX This PR unifies |
My use case is literally just this lol: https://github.com/SUPERCILEX/hardcaml_riscv/blob/595a0992b3afac011a540daf9db0c1c4c3cc3b4c/soft/offchip/tstp/src/main.rs#L39 So I think this PR is good—can't test it though as I don't have my FPGA with me. One thought: maybe it makes sense to have a |
a05280f
to
74d07c9
Compare
Sounds good. I've now implemented your idea of a let mut termios = tcgetattr(&device).unwrap();
termios.set_speed(baud_rate);
tcsetattr(&device, OptionalActions::Drain, &termios).unwrap(); This API takes care of the So again, this is more than rustix would typically abstract away, and I'm still debating it, but there are so many portability hazards between OS's and architectures that I'm leaning towards it. |
This is awesome, thanks! |
74d07c9
to
d82ef59
Compare
This PR turns out to encounter what turned out to be some bugs in bitflags around the handling of unnamed bits. I've now added some workarounds to get the tests passing, but this will need some further planning. |
d82ef59
to
d9c41dd
Compare
Instead of defining `Termios` as a plain alias for the libc `termios` type, define our own `Termios` struct with a libc-compatible layout, so that we can use `bitflags` flags types, and have better overall ergonomics. This encapsulates the `termios` vs. `termios2` difference on Linux, and supports arbitrary I/O speeds on both Linux and BSDs with a consistent interface. This is a little higher-level than rustix typically aims for, but it doesn't incur extra syscalls or even extra `Termios` struct copies, and the things it hides are both awkward and uninteresting, such as the whole termios vs. termios2 split which only happens on Linux, where you have to use termios2 to support arbitrary speeds but you can't use termios2 with `cfmakeraw` etc., and also `c_ispeed`/`c_ospeed` work differently in termios2. And PowerPC lacks termios2 but has a termios that acts like termios2. And MIPS adds `TCSETS` to its `TCSANOW` etc. values.
d9c41dd
to
090a6fa
Compare
I've now filed #695 to track the workarounds. |
Instead of defining
Termios
as an alias for the libc type, define our own type with a libc-compatible layout, so that we can usebitflags
flags types, and have better overall ergonomics.