Académique Documents
Professionnel Documents
Culture Documents
search
The play ground is a publicly -editable wiki about Arduino. Interfacing... Manuals and Curriculum Board Setup and Configuration Development T ools Interfacing With Hardware Output Input User Interface Storage Communication Power supplies General Interfacing with Software Code Library and T utorials Libraries Tutorials Suggestions & Bugs Electronics Technique Sources for Electronic Parts Related Hardware and Initiatives Arduino People/Groups & Sites Exhibition Project Ideas Languages PARTICIPATE Create an account Suggestions Formatting suggestions All recent changes PmWiki WikiSandBox training Basic Editing Cookbook (addons) Documentation index T ODO: Is there any problem with buffering (and if so, how do we flush) if we send content with no end of line:
echo -n "Hello" > /dev/ttyUSB0
arduino.cc/playground//LinuxTTY
1/4
7/9/2011
edit SideBar
Using 'screen' and the SimpleMessageSystem to provide an interactive session with Arduino
1) Program the Arduino with the example code include in the SimpleMessageSystem library (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) T ype the following commands, followed by pressing the enter/return key for each message (please be warned that the characters will not appear as you type them, but the Arduino rx/tx leds will blink, this is considered normal behavior): w d 13 1 ra rd T he first message will turn on a let connected to port 13. T he second message will return the value of all the analog inputs. T he third message will return the value of all the digital inputs. 8/7/08-by Roland Latour (rolandl@cavenet.com) T here'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 interprets and formats the data. Now with a GUI provided by the Xdialog command. Run 'wget http://user.cavenet.com/rolandl/SMS1.tgz' to get the tarball. Added 6/16/2009-by Lee:
Workaround for using cat /dev/ttyUSB0 and screen /dev/ttyUSB0 on a Linux computer.
On my system, the Arduino development environment doesn't close the port /dev/ttyUSB0 quite right. T he scheme for my project is to send serial data out the USB type B connector on my Arduino Mega into a file. Open the file in a spreadsheet..
arduino.cc/playground//LinuxTTY
2/4
7/9/2011
Specifically: The arduino-0015 development application does not close or release /dev/ttyUSB0 on Linux systems completely. As a result, "cat /dev/ttyUSB0" fails if you have used the serial data display in the Arduino development application. T o 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 kill screen using the PID in column two.
ps aux // see screen and SCREEN processes. Note PID in column 2 kill 9264 9265 // screen is gone and "cat /dev/ttyUSB0" now works
Background about the environment for these commands. My Arduino hardware is an Arduino Mega that has a USB type B port built in. The program application uses serial data setup and printing straight out of the Arduino Programming Notebook. In the Arduino development environment, I can see the data being printed by the Arduino board using the Serial Monitor button. This should work before you can get data from /dev/ttyUSB0. T he computer 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); }
arduino.cc/playground//LinuxTTY
3/4
7/9/2011
Plug in the Arduino into the USB and type in the terminal:
$ ls tty*
Y our program in Arduino must have initialised Serial Interface at a speed with Serial.begin(<speed>). T he interface you are going to run ('cu') is so simple that every keypress will be sent to the serial device without echo, and every char sent by Arduino will be sent to your screen. T here is no chance to stop 'cu', only by killing the T erminal window you are running. T ype in the terminal:
$ cu -l /dev/<device> -s <speed>
In my case:
$ cu -l /dev/ttyACM0 -s 115200
Share |
arduino.cc/playground//LinuxTTY
4/4