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:
Martin Lund 2017-11-13 12:58:50 +01:00
parent 23bab24890
commit e646c50019
4 changed files with 68 additions and 13 deletions

20
src/setspeed2.c Normal file
View 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;
}