Reputation: 35
I'm not very experienced with the Linux tty's. My environment is a Raspbian with a prolific USB-serial.
What works:
stty -F /dev/ttyUSB0 38400
cu -l /dev/ttyUSB0 -s 38400
cu
to /dev/ttyUSB0
works. I can write my commands to the terminal and get response from the other terminal within 300ms.
What not works: in one terminal
echo "command" > /dev/ttyUSB0
in another terminal (running before echo)
cat < /dev/ttyUSB0
or
tail -f /dev/ttyUSB0
there is no output.
But when i echo "command" > /dev/ttyUSB0
and have cu
open, I can see the echoed command and the response from the other terminal there.
What am I missing?
best regards
Sundypha
ps: What I tried too, was a little python script:
#!/usr/bin/python
import serial
ser = serial.Serial('/dev/ttyUSB0', 38400, xonxoff=True)
ser.open()
if ser.isOpen():
ser.write('command')
response = ser.readline()
print response
ser.close()
did not work either, hangs on ser.readline()
Upvotes: 3
Views: 12897
Reputation: 210
If you are not cat'ing the USB0 device as you echo to it, then yes, you will not see its output because it has been and gone.
try something like:
tail -f /dev/ttyUSB0
and then echo stuff into it.
Upvotes: 0