Hi all,
Just joined the forum and also new to Linux so decided to try Puppy as my entry point for my Linux "adventures".
Can anyone shed some light on how one would go about writing a script that would automatically upload some data to a website (preferably via http but ftp also OK) each time a byte is received on the serial port?
Thanks in advance,
Dave.
Need script to automatically upload data from serial port
Help needed by newbie
Hi darkcity,
A Bash script would be fine.
What I require is the script to check the serial ports buffer (for received ASCII data) and then automatically upload that as a text file to a server.
The file will always have the same name and any previous uploads are over-written by the new upload.
Thanks,
Dave.
A Bash script would be fine.
What I require is the script to check the serial ports buffer (for received ASCII data) and then automatically upload that as a text file to a server.
The file will always have the same name and any previous uploads are over-written by the new upload.
Thanks,
Dave.
My suggestion would be re-post in the Programming section (which isn't really off topic)
http://www.murga-linux.com/puppy/index.php?f=46
If you have no joy there. Post here again in this thread and I will look into it.
http://www.murga-linux.com/puppy/index.php?f=46
If you have no joy there. Post here again in this thread and I will look into it.
Help needed by newbie
No problem, thanks.
Apologies for posting in the wrong place.
Dave.
Apologies for posting in the wrong place.
Dave.
-
- Posts: 452
- Joined: Thu 20 Mar 2008, 01:48
Hi,
I will try to help...
in your problem, you need to scan serial port which will trigger upload or download right ???
i check some program and find these
http://stackoverflow.com/questions/3701 ... bstitution
http://crunchbanglinux.org/forums/topic ... tp-server/
other alternative....
http://nixcraft.com/shell-scripting/157 ... ouble.html
i hope that help
I will try to help...
in your problem, you need to scan serial port which will trigger upload or download right ???
i check some program and find these
http://stackoverflow.com/questions/3701 ... bstitution
about sending files i find these...# initialize serial port
stty 2000000 -ixon icanon </dev/ttyUSB0
# check settings
stty -a -F /dev/ttyUSB0
# in one terminal - read from serial port
while (true) do cat -A /dev/ttyUSB0 ; done
# in other terminal - write to serial port
echo "1234567890" > /dev/ttyUSB0
# back to first terminal, I now have:
# $ while (true) do cat -A /dev/ttyUSB0 ; done
# 1234567890$
# ...
http://crunchbanglinux.org/forums/topic ... tp-server/
cd $filedir
wput ftp://$user:$pass@$host/$targetfile
other alternative....
http://nixcraft.com/shell-scripting/157 ... ouble.html
I got it to work!!!!!
The problem was when this line : "cat /dev/ttyS0 > $mytestfile"
would get called, the script would run correctly but it would keep the serial port open forever like bill stated above, which is why i could never run a single command after wards.
So to fix this I did this:
#!/bin/bash
stty -F /dev/ttyS0 9600 cs7 parenb parodd -cstopb clocal -crtscts -ixon -ixoff
mytestfile=mmof.txt
cat /dev/ttyS0 >> $mytestfile
I have this script run in the background at boot up, and it continues to run the entire time the computer is on leaving the port open.
Then I just run the other script:
#!/bin/bash
stty -F /dev/ttyS0 9600 cs7 parenb parodd -cstopb clocal -crtscts -ixon -ixoff
echo "200 201" > /dev/ttyS0
i hope that help
Cluster-Pup v.2-Puppy Beowulf Cluster
[url]http://www.murga-linux.com/puppy/viewtopic.php?p=499199#499199[/url]
[url]http://www.murga-linux.com/puppy/viewtopic.php?p=499199#499199[/url]
- Moose On The Loose
- Posts: 965
- Joined: Thu 24 Feb 2011, 14:54
Re: Need script to automatically download data
bash can do actions on the network directly. A HTTP transfer of a text file is not all that hard to do. You send the HTTP post line over the network and then a blank line and then the body of the file.Dave_G wrote:Hi all,
Just joined the forum and also new to Linux so decided to try Puppy as my entry point for my Linux "adventures".
Can anyone shed some light on how one would go about writing a script that would automatically upload some data to a website (preferably via http but ftp also OK) each time a byte is received on the serial port?
Thanks in advance,
Dave.