Reputation: 49
I want to send an AT command and read response from bash script. My code is like:
stty -F /dev/ttyS5 9600
echo "AT" > /dev/ttyS5
timer=0
while read -rs -n 1 c
do
echo "$c" >> test
echo "$c"
((timer++))
sleep 1
if [ "$timer" == 3 ] ; then
break
fi
done < /dev/ttyS5
then i want to read from test file the response is OK or not. But my scripts output be like:
senseless value
O
K
when i read that i had some troble. What is the best way of checking AT command response?
Upvotes: 0
Views: 868
Reputation: 330
You will be much happier, assuming you can install software in your environment, in searching for a package for communicating on a tty line. cu
and minicom
come to mind. Also, you might want to look at expect
for scripting keystrokes and checking responses.
Using bash
this way will be quite a challenge.
Upvotes: 1