Forum 2005-2010 (read only) > Interfacing

Linux Serial IO

<< < (3/3)

I am trying to set up an Arduino Diecimila to power-cycle a device under control of a Linux application.  The hardware is working.  The Arduino code (using 0015) looks like this:

--- Code: ---int outputPin = 3;
int val;

void setup()
 pinMode(outputPin, OUTPUT);

void loop()
 if (Serial.available()) {
   val =;
   if (val == 'R') {
     digitalWrite(outputPin, HIGH);
   digitalWrite(outputPin, LOW);
--- End code ---

Everything works fine from the Arduino development environment.  On Linux, I set up the /dev/ttyUSB3 port using the stty command above with the correct baud rate and then echo "R" > /dev/ttyUSB3.  However, the only way I can get the Arduino program to recognize the "R" is if I start another Linux session and invoke tail -f /dev/ttyUSB3 first.  

Without the tail command, sending the "R" character causes the Rx LED to blink, quickly followed by the 'L' (Pin 13) LED.  Starting the tail command causes the 'L' LED to blink.  Sending the "R" now causes just the Rx LED to blink.  I tried throwing in a Serial.flush() but that did not seem to do anything.

Am I missing something obvious?  Running a tail command in the background is not a big deal, other than it 'holds' the ttyUSB3 port.  If I unplug/replug the Arduino, I end up on /dev/ttyUSB4.
   Thanks, Norbert

This is caused by the auto-reset feature ! Every time you open a _new_ serial connection the Arduino gets a reset.

That's why you can disable it by cutting the RESET_EN trace on Duemilanove and Mega boards.

So the tail[/] command kept the serial connection open?

Now that I know what to look for, there are a lot of forum posts on this subject.  I will try the 120 ohm resistor technique.
    Thanks for the fast response!

Yup, you've got it.

I know that problem all to well. Thankfully my complaints were heard and the new boards were improved :-)

Rado at suggested adding the -hupcl option on the stty command.  This worked like a charm! I can now echo commands to the Arduino without any fuss or bother.


[0] Message Index

[*] Previous page

Go to full version