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:
int outputPin = 3;
int val;
void setup()
{
Serial.begin(9600);
pinMode(outputPin, OUTPUT);
}
void loop()
{
if (Serial.available()) {
val = Serial.read();
if (val == 'R') {
digitalWrite(outputPin, HIGH);
delay(5000);
}
digitalWrite(outputPin, LOW);
}
}
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