I have a pretty simple bash script that sends command to serial and reads thee value back. The problem is when I don't get a value back,, it can get stuck.
echo BC > /dev/ttyS1
read line < /dev/ttyS1
echo $line
I have used the cat command with a timeout, but cannot use the same technique with 'read', because if I send the process to the background, I never get value back on exit. 'cat' works for the most part, but i'm not sure if this is the most robust way to do this.
echo BC > /dev/ttyS1
cat /dev/ttyS1 &
pid=$!
sleep 0.1
kill -9 $pid