I have a script monitoring a serial port loopback.
while sleep 1; do echo "1" > /dev/ttyS0; done &
while read -t 2 < /dev/ttyS0; do xxxx; done
The above works, however if I just do an echo outside of the while loop and &, it doesnt work as it never gets a successful read, such as below.
echo "1" > /dev/ttyS0 #This is just to get the while loop started.
while read -t 2 < /dev/ttyS0; do
sleep 1
echo "1" > /dev/ttyS0
done
I'm trying to send data down the serial port (any data idc) and verify I get a reply. Is there a better way of doing this? Why does the above not work?