0

I'm trying to write to my arduino through the serial port:

#!/bin/bash
exec 3<> /dev/ttyACM0 
echo "v" >&3
cat <&3  
exec 3>&-

The based on the letter it receives it should return the value from one of the sensors. For simplicity I replaced that with millis().

void loop() {
  if (Serial.available() > 0) {
    incomingByte = Serial.read();
    if (incomingByte == 118){
      Serial.println(millis());
      Serial.end();
    }
  }
}

The problem I'm having is that when I execute that bash script, it never returns the promt, the "cat" command keeps waiting for more.

I have tried Serial.write(0) and Serial.write(4) (instead of Serial.end()) that are supposed to be EOF chars, but it still won't return the promt.

I also tried cat <&3 | head -n 1

But still, cat never returns.

Any thoughts?

(I'm doing all of this on a mr3020 with no pendrive for extra space, so python is out of the question)

diCoy
  • 79
  • 2
  • 9
  • 2
    Did you try without cat command? Just **head -n 1 <&3** – pelya May 15 '15 at 16:43
  • Do the above commands work via a 'tty session'? Did you include the code for serial I/O? I did something similar using 'screen' - might be helpful: http://web-tech.ga-usa.com/2011/06/arduino-serial-time-with-screen-and-other-tools/ :) – Dale_Reagan May 15 '15 at 18:32
  • Just **head -n 1 <&3** worked fine. Thanks!! :) – diCoy May 15 '15 at 20:18

0 Answers0