I have bought a serial - USB adapter to connect my UPS (serial equipped) to my Raspberry machine and therefore to monitor the UPS.
The adapter is seen as /dev/USB1. The baud rate is 2400, the data lenght is 8 bit, stop bit 1 bit and no parity.
To get the status of the UPS, I should send to serial the command “Q1” followed by “cr” and then to read the output of the serial.
I have found following script:
tty=/dev/ttyUSB1
exec 4<$tty 5>$tty
stty -F $tty 9600 -echo
echo ‘Q1\n\r’ >&5
read reply <&4
echo "reply is $reply"
but it works just once and then it get stuck when executing the read command.
It looks like the serial get stuck after the first enquiry and then it returns alive after a few hours. Could it be?
Can anyone please help me?
Thanks, Daniele
‘
should have been'
. That's one thing a see wrong with this script! – George Udosen Nov 15 '17 at 22:39screen
orbyobu
. Don't bother with file descriptors. And add yourself todialout
group, since tty devices are owned by that group – Sergiy Kolodyazhnyy Nov 15 '17 at 22:46