Controlling serial ports in Linux

From RidgeRun Developer Connection
Jump to: navigation, search


Built-in serial ports in embedded Linux devices typically show up as


You can configure the serial port using the Busybox stty command.

Configuring baudrate

Here is the stty command I use to set the baud rate:


stty -F $serial_port $baud intr ^C quit ^D erase ^H kill ^U eof ^Z eol ^J start ^Q stop ^S -echo echoe echok -echonl echoke -echoctl -istrip -icrnl -ocrnl -igncr -inlcr onlcr -opost -isig -icanon cs8 -cstopb clocal -crtscts -ixoff -ixon -parenb -parodd -inpck

To test the changed baudrate, on a host PC I use picocom.

picocom -b 9600 -r -l /dev/ttyUSB3

where /dev/ttyUSB3 is my host's serial port (via a USB RS-232 dongle).