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)