OpenWrt/acemonstertoys-serial: Difference between revisions
< OpenWrt
(Die Seite wurde neu angelegt: „== Interfacing with Arduino == Prereqs opkg install the following coreutils-stty - 8.8-1 (lets you talk to serial ports) kmod-usb-serial - 2.6.39.4…“) |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Interfacing with Arduino == | == Interfacing with Arduino == | ||
<blockquote> | |||
<pre> | |||
opkg install coreutils-stty | |||
</pre> | |||
</blockquote> | |||
Script to read from arduino | Script to read from arduino | ||
<blockquote> | |||
<pre> | |||
#!/bin/sh | #!/bin/sh | ||
#/usr/bin/readuino.sh | #/usr/bin/readuino.sh | ||
Line 45: | Line 37: | ||
fi | fi | ||
</pre> | |||
</blockquote> |
Latest revision as of 10:18, 1 October 2012
Interfacing with Arduino
opkg install coreutils-stty
Script to read from arduino
#!/bin/sh #/usr/bin/readuino.sh # simple script to tail newline terminated messages from the arduino # adjust the head number depending on your arduino messages if ! [ -f /tmp/isrunning ]; then if [ -c /dev/ttyUSB0 ]; then echo $$ > /tmp/isrunning /usr/bin/stty -F /dev/ttyUSB0 raw speed 9600 while [ 1 ]; do if [ -c /dev/ttyUSB0 ]; then head -n 3 /dev/ttyUSB0 >/tmp/volts sleep 1 else # USB dissapeared. echo "Arduino no longer attached" >/tmp/volts rm /tmp/isrunning exit fi done else echo "Arduino not yet attached" >/tmp/volts fi fi