-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
Since glibc 2.42 Linux glibc supports arbitrary baud rates directly; several other Unices have done that for a long time.
The code in serial.c has several serious problems, however:
- Manipulating c_cflag directly is not the correct way to set baud rates for any system; that was the method used with the termio (not termios) interface, but termios has always required the use of cfset[io]speed().
- If the Bxxx constants match the respective xxx values then it should be safe to use them as integers directly. For Linux specifically, you can simply test for B300 == 300.
- Don't use TIOCGSERIAL for these newer systems; using TIOCGSERIAL breaks other applications.
- Glibc 2.42 added cfset[io]baud() which is explicitly defined as numeric, if you don't trust relying on testing the Bxxx constants; however, that will not yet work on other Unices.
The stty code in GNU coreutils has been augmented with autodetection of supported speeds to a specific platform. You might find that interesting as an example.
Metadata
Metadata
Assignees
Labels
No labels