[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: STTY arbitraty baudrate
From: |
Pádraig Brady |
Subject: |
Re: STTY arbitraty baudrate |
Date: |
Sun, 16 Apr 2017 19:56:16 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
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.