dcuddeback / termios-rs

Safe bindings for the termios library.
http://dcuddeback.github.io/termios-rs/termios/
MIT License
75 stars 26 forks source link

Make `c_ispeed` and `c_ospeed` public. #8

Closed mbr closed 7 years ago

mbr commented 7 years ago

Access to these fields is important when setting custom transmission rates; make them accessible for other libraries.

This PR is in anticipation of a new feature for serial-rs, allowing custom bitrates to be set.

dcuddeback commented 7 years ago

@mbr These fields are not part of the POSIX spec, but cf{set,get}{i,o}speed() are, which is a portable way to set and get the baud rates.

mbr commented 7 years ago

@dcuddeback How do i set a bitrate of 12345 baud?

cfsetospeed() sets the output baud rate stored in the termios structure pointed to by termios_p to speed, which must be one of these constants:

[...]

I don't think it's possible to set a nonstandard speed this way (that does not have a constant defined).

cfsetispeed is limited to the struct termios structure, which does not carry these fields. What termios-rs labels pub struct termios is actually a struct termios2 (see link for a comparison). The C struct termios does not carry the c_ispeed/c_outspeed fields, for this reason, non-standard bitrates cannot be stored in it.