Serial ports usage on Linux

From ArmadeusWiki
Revision as of 23:12, 29 January 2009 by JulienB (Talk | contribs) (creation)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How to use the serial ports on Linux.

On Linux all serial ports are driven the same way with their device nodes:

  • /dev/ttySMXn for i.MX own ports (/dev/ttySMX0 is the default console on which you can interact with the board)
  • /dev/ttyUSBn for USB <-> serial converters
  • /dev/ttySn for 16550 compatible FPGA's IP

Changing port parameters

  • Get current parameters:
# stty -F /dev/ttySMX0
speed 115200 baud;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ^J;
eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-brkint ixoff -imaxbel
-iexten -echoctl

Sending/Receiving data

  • It is simple as opening the device as a file and writing data to it:
# echo "HELLO" > /dev/ttySMX0
  • To receive data (ASCII in that case):
# cat /dev/ttySMX0