Wednesday, December 1, 2010

serial port

Get which serial port device is active
$ dmesg | grep tty

Get the bard rate of serial port device sttyS0
$stty -F /dev/sttyS0

Put some data in serial port
$echo hello > /dev/sttyS0

receive data from serial port of other machine (if use USB to receive)
$cat /dev/ttyUSB0

usually, you will see binary data from terminal. You could use minicom to receive data
Install minicom
$sudo apt-get install minicom

Start minicom and save output
$minicom -C output

If you didn't set up the serial port, you need set up first, run
$minicom -s

Setup the device and baud rate. you could run following cmd to see the device
$ls /dev/tty*

I assume you use USB, the you could see /dev/ttyUSB0. set the device to /dev/USB0 in the minicom. and You need to set the bard rate. Usually, it is 9600, some times it would be 115200(like coreboot set the serial port rate)

Finally, you will see data from terminal, you could also save the output.

No comments: