mirror of
https://github.com/tio/tio.git
synced 2026-05-01 23:07:58 +02:00
Add support for setting non-standard baudrates
Support for non-standard baudrate settings will be automatically enabled if the termios2 interface is detected available. However, to play it safe, the old and widely supported termios interface will still be used when setting standard baudrates.
This commit is contained in:
parent
23bab24890
commit
e646c50019
4 changed files with 68 additions and 13 deletions
20
src/setspeed2.c
Normal file
20
src/setspeed2.c
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include <sys/ioctl.h>
|
||||
#include <asm/termbits.h>
|
||||
|
||||
int setspeed2(int fd, int baudrate)
|
||||
{
|
||||
struct termios2 tio;
|
||||
int status;
|
||||
|
||||
status = ioctl(fd, TCGETS2, &tio);
|
||||
|
||||
// Set baudrate speed using termios2 interface
|
||||
tio.c_cflag &= ~CBAUD;
|
||||
tio.c_cflag |= BOTHER;
|
||||
tio.c_ispeed = baudrate;
|
||||
tio.c_ospeed = baudrate;
|
||||
|
||||
status = ioctl(fd, TCSETS2, &tio);
|
||||
|
||||
return status;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue