Controlling serial ports in Linux

From RidgeRun Developer Wiki


Introduction

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

/dev/ttyS0
/dev/ttyS1

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:

serial_port=/dev/ttyS0
baud=9600

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).



For direct inquiries, please refer to the contact information available on our Contact page. Alternatively, you may complete and submit the form provided at the same link. We will respond to your request at our earliest opportunity.


Links to RidgeRun Resources and RidgeRun Artificial Intelligence Solutions can be found in the footer below.