Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a serial port device that I would like to test using linux command line.

I am able to use stty and echo for sending commands to serial port, but when device responds I have no way of reading what is coming from serial port. I am using

stty -F /dev/ttyS0 speed 9600 cs8 -cstopb -parenb && echo -n ^R^B > /dev/ttyS0

to send a command to the device. Device operates and sends a response back in 300 ms's and but I don't know how I can print that response to the console using command line, if someone can show me a way to do this, I'd be grateful.

share|improve this question

migrated from stackoverflow.com Jul 5 '12 at 14:30

This question came from our site for professional and enthusiast programmers.

up vote 26 down vote accepted

Same as with output. Example:

cat /dev/ttyS0


cat < /dev/ttyS0

The first example is an app that opens the serial port and relays what it reads from it to its stdout (your console). The second is the shell directing the serial port traffic to any app that you like; this particular app then just relays its stdin to its stdout.

To get better visibility into the traffic, you may prefer a hex dump:

od -x < /dev/ttyS0
share|improve this answer
thaks a lot worked like a charm – erin c Jul 4 '12 at 14:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.