Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there any way to check which baud rates are supported for a serial device on Linux?

I've poked around the /sys/class/tty/ttyS0 directory, but I can't see anything in there that lists this type of information.

share|improve this question
1  
I would hesitate to say it's available unless the driver controlling the device is 100% compatible. I'd go to the manufacturer's documentation to be sure. –  user3463 Oct 16 '12 at 16:07
add comment

2 Answers

up vote 1 down vote accepted

You seem to be asking two different questions.

Is there any way to check which baud rates are supported on a serial device?

The answer would depend on (1) the capabilities of the hardware, i.e. the UART/USART/SCC, and the range of divisors that the device driver can use in the baud rate generator; consult the device data sheet; (2) the frequency of the clock/oscillator connected to the serial port device; consult the board documentation.

Is there any way to check which baud rates are supported on Linux?

The one of the defined baud rates in include/asm-generic/termbits.h for the *c_cflag* member of the terminal control structure is the typical method that the serial port (i.e. UART/USART) device driver receives for the baud rate configuration value.

#define  B0     0000000         /* hang up */
#define  B50    0000001
#define  B75    0000002
#define  B110   0000003
#define  B134   0000004
#define  B150   0000005
#define  B200   0000006
#define  B300   0000007
#define  B600   0000010
#define  B1200  0000011
#define  B1800  0000012
#define  B2400  0000013
#define  B4800  0000014
#define  B9600  0000015
#define  B19200 0000016
#define  B38400 0000017

#define    BOTHER 0010000
#define    B57600 0010001
#define   B115200 0010002
#define   B230400 0010003
#define   B460800 0010004
#define   B500000 0010005
#define   B576000 0010006
#define   B921600 0010007
#define  B1000000 0010010
#define  B1152000 0010011
#define  B1500000 0010012
#define  B2000000 0010013
#define  B2500000 0010014
#define  B3000000 0010015
#define  B3500000 0010016
#define  B4000000 0010017

Serial port drivers typically do not have any means of reporting/advertising which of these baud rates are actually supported/configurable/implemented. There is a capabilities value for attributes like FIFO and sleeping but not for baud rates. A driver could define an ioctl() call to configure (nonstandard) baud rates, although that would make programs using it non-portable.

share|improve this answer
add comment

You can check the device baud rate using the "stty" command on the console:

$ stty < /dev/tty..      (where tty... is the device file you are listening)  

output:

speed 9600 baud; line = 0;
-brkint -imaxbel

You can also change the baud rate with the following command:

$ sudo stty -F /dev/tty... 9600    (or whatever baud rate number)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.