I am a bash novice and I am struggling with putting it all together.
What I am trying to do is:
1) Set Port (stty)
2) Read from dev/ttyUSB0 - data should look like 000118110000101 (cat or Gawk?)
3) Set read data into a variable eg DATA and create a URL eg http://domain.com/get_data.php?data=$DATA
4) load the URL with wget?
5) Wait for more data from ttyUSB0 (polling or loop?)
I have tried the php DIO extention that does work but is not reliable because it stops/starts for some reason.
ANY suggestions would be much appreciated, I will be very great-full if anyone could advise the best way to do this
Thanks
Brent
This is what I used.
#Set permisions
sudo chmod o+rwx /dev/ttyUSB0
#!/bin/bash
# Port setting
stty -F /dev/ttyUSB0 cs7 cstopb -ixon raw speed 1200
# Loop
while [ 1 ];
do
echo 'LOADING...'
READ=`dd if=/dev/ttyUSB0 count=22 | sed 's/ //g'`
echo $READ
wget http://localhost/BASHtest/test.php?signal=$READ
echo '[PRESS Ctrl + C TO EXIT]'
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With