Controlling serial ports in Linux: Difference between revisions

From RidgeRun Developer Wiki
(Created page with '== Introduction == Built-in serial ports in embedded Linux devices typically show up as <pre> /dev/ttyS0 /dev/ttyS1 </pre> You can configure the serial port using the [http://...')
 
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<seo title="Linux Serial Port Programming | Control Linux Serial Ports" titlemode="replace" keywords="GStreamer, Linux SDK, Linux BSP,  Embedded Linux, Device Drivers, Nvidia, Xilinx, TI, NXP, Freescale, Embedded Linux driver development, Linux Software development, Embedded Linux SDK, Embedded Linux Application development, GStreamer Multimedia Framework."  description="This useful wiki document contains information on controlling serial ports in Linux. Learn about Linux serial port programming from RidgeRun today."></seo>
== Introduction ==
== Introduction ==


Line 28: Line 30:




[[Category:HowTo]]
[[Category:HowTo]][[Category:Ubuntu]]

Latest revision as of 20:16, 26 January 2018


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