Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
Arduino Playground - LinuxTTY

Arduino Playground - LinuxTTY

Ratings: (0)|Views: 92|Likes:
Published by Manoj Acharya

More info:

Published by: Manoj Acharya on Apr 12, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

04/12/2012

pdf

text

original

 
The playground is a publicly-editablewiki about Arduino.
Manuals and CurriculumBoard Setup and ConfigurationDevelopment ToolsInterfacing With HardwareOutputInputUser InterfaceStorageCommunicationPower suppliesGeneralInterfacing with SoftwareCode Library and TutorialsLibrariesTutorialsSuggestions & BugsElectronics TechniqueSources for Electronic PartsRelated Hardware andInitiatives Arduino People/Groups & SitesExhibitionProject IdeasLanguagesPARTICIPATECreate an accountSuggestionsFormatting suggestions All recent changesPmWiki WikiSandBox trainingBasic EditingCookbook (addons)Documentation indexMain Site Blog Playground Forum StoreHelp|Sign in or Register 
search
Interfacing...
Arduino and Linux TTY
Elliott Kipp/edk4971 posted in the forums onhow to configure a linux tty with the correct parity, baud, etc to talk to arduino.Repeating it here:stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtsctsmake sure /dev/ttyUSB0 or whatever is your arduino, and 115200 is the baud you did your Serial.begin(XXXX) with You can then do:
echo "Hello Arduino" > /dev/ttyUSB0to send the string (followed by a newline) to your arduino.
Taken from this forum:http://www.crystalfontz.com/forum/showthread.php?p=19562 You can also do:
tail -f /dev/ttyUSB0to read what your arduino has to tell you.
TODO: Is there any problem with buffering (and if so, how do we flush) if wesend content with no end of line:
echo -n "Hello" > /dev/ttyUSB0
Using 'screen' to provide an interactivesession with arduino
this first commenton todbot's post on serial c code to talk to arduino showshow to get an interactive session with arduino using thescreencommand.
screen /dev/cu.usbserial 9600
I haven't tested this yet.
7/9/2011 Arduino playground - LinuxTTYarduino.cc/playground//LinuxTTY 1/4
 
edit SideBar
Using 'screen' and theSimpleMessageSystemto provide aninteractive session with Arduino
1) Program the Arduino with the example code include in theSimpleMessageSystemlibrary (leave the baud rate at 9600 for this example).2) Open a terminal window.3) Enter the following command (that differs slightly from above):
stty -F /dev/ttyUSB0 cs8 9600 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
4) Start
screen
by typing the following:
screen /dev/ttyUSB0 9600
5) Start by pressing the enter/return key to clear the Arduino's buffer.6) Type the following commands,
followed by pressing the enter/returnkey for each message
(please be warned that the characters will not appearas you type them, but the Arduino rx/tx leds will blink, this is considerednormal behavior): w d 13 1r ar dThe first message will turn on a let connected to port 13. The second message will return the value of all the analog inputs. The third message will return the value of all the digital inputs.8/7/08-by Roland Latour (rolandl@cavenet.com) There's a better way.'screen' actually forks a second process to catch data coming the other way. So you need a helper process. My shell script package does that, and interpretsand formats the data. Now with a GUI provided by the Xdialog command. Run'wgethttp://user.cavenet.com/rolandl/SMS1.tgz' to get the tarball. Added 6/16/2009-by Lee:
Workaround for using cat /dev/ttyUSB0and screen /dev/ttyUSB0 on a Linuxcomputer.
On my system, the Arduino development environment doesn't close the port/dev/ttyUSB0 quite right.The scheme for my project is to send serial data out the USB type B connectoron my Arduino Mega into a file. Open the file in a spreadsheet..
7/9/2011 Arduino playground - LinuxTTYarduino.cc/playground//LinuxTTY 2/4
 
cat /dev/ttyUSB0 > datafilegnumeric < datafile
Specifically: The arduino-0015 development application does not close orrelease /dev/ttyUSB0 on Linux systems completely. As a result, "cat /dev/ttyUSB0" fails if you have used the serial data display inthe Arduino development application.To re-capture the data use "screen"
screen /dev/ttyUSB0 // Kill screen with ^ak or control-a k
 An alternate way to stop the screen program: Display the process table and killscreen using the PID in column two.
ps aux // see screen and SCREEN processes. Note PID in column 2kill 9264 9265 // screen is gone and "cat /dev/ttyUSB0" now works
Background about the environment for these commands. My Arduinohardware is an Arduino Mega that has a USB type B port built in. The programapplication uses serial data setup and printing straight out of the
 ArduinoProgramming Notebook 
. In the Arduino development environment, I cansee the data being printed by the Arduino board using the Serial Monitor button. This should work before you can get data from /dev/ttyUSB0. Thecomputer runs a mix of Ubuntu 7.10 and 8.04.Serial port code fragments:
setup(){Serial.begin(9600);}loop(){Serial.print("Total ");Serial.println(total_count/1000);}
End of note by Lee. Added 9-jun-2011 - by The Dare Guy (http://twitter.com/thedareguy ):
Simple communication using 'cu' in Linux(tested in Ubuntu 10.04 LTE)
Find what USB port uses Arduino when you plug it into your computer. It can be something like /ttyUSBx or /ttyACMx (this is my case). To find the answerunplug the Arduino from the USB, run a Terminal (Applications > Accesories> Terminal) and type:
$ cd /dev$ ls tty*...tty8tty9
7/9/2011 Arduino playground - LinuxTTYarduino.cc/playground//LinuxTTY 3/4

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->