I wrote Arduino sketch and it works. It waits for a command and answers text on response.
Simultaneously, I can't get any response with command line tools.
For example, I have the following code to get temperature:
#!/bin/bash
tty=/dev/ttyUSB0
exec 4<$tty 5>$tty
stty -F $tty cs8 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
#stty -F $tty 9600 -echo
#printf "temp\n" >&5
echo temp >&5
read reply <&4
echo "$reply"
#tail -n 1 - <&4
It returns empty or hang under different circumstances.
Also, if I run built-in Serial Monitor
, I can see responses on command lines like:
echo temp > /dev/ttyUSB0
But I see nothing with commands like tail -f /dev/ttyUSB0
What I am doing wrong?