Read output from ttyUSB0

1.9k views Asked by At

After installing one relay board in respberry pi I tested with success some commands to open and close the relays but I found one problem. I do not receive the status of the eight relays or the status of single relay. How can I fix this?

The permission that I added in ttyUSB0 #chmod o+rwx /dev/ttyUSB0

#!/bin/bash

stty -F /dev/ttyUSB0 9600

# Command to get the status of eight relays.
echo -e '\xff\x09\x00' > /dev/ttyUSB0 

while true; do

cat /dev/ttyUSB0

done

exit

Note: in C code the output works fine. http://www.kmtronic.com/software/Raspberry_PI/Raspberry_PI_KMTronic_USB_Relay.zip

1

There are 1 answers

2
Dennis Kerrisk On

If you are trying to get the status you should be sending: echo -e '\xff\x01\x03' > /dev/ttyUSB0