I have two computers with two serial ports: ttyS0 and ttyUSB0. (Actually they are on the same computer but that's just for testing). The ports are connected via null modem cable. I want to be able to simply send bytes into one end and come out the other end, and vice versa. Why doesn't the below work?:
# set both serial ports to 9600 8n1 # `-parenb` means no parity, # `-cstopb` means 1 stop bit # cs8 means 8 bits at a time stty -F /dev/ttyUSB0 cs8 -cstopb -parenb 9600 stty -F /dev/ttyS0 cs8 -cstopb -parenb 9600 # in one terminal: echo "asdf" > /dev/ttyUSB0 # in another terminal, this hangs and does nothing cat < /dev/ttyS0
I can do similar things with
netcat and pipes very easily (below), so I feel something like the above should be possible as well.
mkfifo mypipe # in one terminal cat < mypipe # in another. works as expected echo "asdf" > mypipe