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. How do I print that response to the console using command line?
Best Answer
Same as with output. Example:
Or:
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 itsstdin
to itsstdout
.To get better visibility into the traffic, you may prefer a hex dump: