I'm trying to find a way to have a bash script read data that another piece of software is sending to a /dev port (such as tty/pts/usb/serial). Specifically I'm looking to grab output from "hamlib" (which apparently only sends to certain /dev ports, NOT a txt file!) and parse the output for use with servoblaster. My script works like a charm when the input is a text file, but I've been unable to find a way to link it back to hamlib. A piped FIFO buffer would probably be great if I could make it work...
Here's the script:
Code:
#!/bin/bash
fil=/usr/src/testdata
#fil=/dev/tty20
function hamlibmon()
{
while read line
do
echo $line | grep -q EL
if [ $? == 0 ]; then
elpos=`echo $line | cut -d L -f2 | cut -d . -f1`
elpos=$(echo "scale=3; $elpos*1.1+50" | bc)
echo 0=$elpos > /dev/servoblaster
fi
done < $fil
}
while true
do
hamlibmon
done
fi