On 15/04/17 03:11, lesto fante wrote: > Hello, > > i'm working on some MCU and i need to set arbitrary baudrate; looking > at the code of stty seems like I can only use a baudrate from a > specific list. > > I undertstand those are standard and non-standard things can make > issue, but could it possible to use a flag to say "look stty, i know > waht im doing, give me my 250.000 baud thanks." > >>From what I seen ospeed and ispeed seems to bypass the check, maybe > the solution would be to set this in a manual?
Yes this is confusing. Currently unmatched values get converted to -1 when passed to cfsetospeed(). To determine if the setting is actually support you must read back: On my linux system here B250000 is not supported for example: $ stty speed 38400 $ stty ospeed 250000 $ stty speed 38400 POSIX is quite vague about acceptable inputs to: http://pubs.opengroup.org/onlinepubs/9699919799/functions/cfsetospeed.html The Linux man pages specify certain B... constants must be specified: http://man7.org/linux/man-pages/man3/cfsetospeed.3.html If you use one of those constants you get different results than above $ stty ospeed 230400 stty: 'standard input': unable to perform all requested operations $ stty speed 230400 As for relaxing to specify arbitrary numbers, that wouldn't work on Linux at least as there isn't a direct mapping between B... and value: $ find /usr/include/ -type f | xargs grep -F B230400 /usr/include/bits/termios.h:#define B230400 0010003 Perhaps low level serial control like this is best supported with the setserial command on Linux at least. cheers, Pádraig.
