Finally Got Arduino to Talk To Linux

FINALLY, I been working on this for a while.

I been trying to get Linux to talk to arduino via serial port.

Basically the read is what I am trying to do.

The huge breakthrough was finding a someone that did the source code in C:

Found it here

http://todbot.com/blog/2013/04/29/arduino-serial-updated/

You can download the source with git using the following command

git clone https://github.com/todbot/arduino-serial/

Then go into arduino-serial and run make

Then you got arduino-serial to play with

Here is how I used it in a bash script

#!/bin/bash
COUNTER=1
while [ $COUNTER -eq 1 ]; do
 SERIALCOMMAND=`/home/larry/bin/arduino-serial -b 115200 -p /dev/ttyUSB0 -r | dos2unix | grep "read string" | cut -d\: -f2`
 echo "$SERIALCOMMAND"
 if [ "$SERIALCOMMAND" == "TV" ]; then
 COUNTER=0
 fi
 echo $COUNTER
done

Note the dos2unix command.  It was the cause of major frustration for my script cause of the hidden strings.

Its all good though, it works, now I can run read values into bash on my Linux box.

Triumph

Earned right to be lazy doing pushups and situps then bed.

 

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.