Hi All,
Similar to this post, YunServer + SoftwareSerial = periodic hangs - Arduino Yún - Arduino Forum , I've had hangs when attempting to use software serial with a GPS module. It does work, but it hangs pretty often. I thought I would create another post as I have some example code that tests this. I've stripped out everything but what is necessary. I did have lots of printf's in there, but it doesn't hang in one particular place. It can hang anywhere.
Please try the code below and connect the serial terminal. In this state, it will hang in seconds to tens of seconds. Next, comment out the ss.begin() line. It will then work.
What's going on?
Thanks,
Phil
#include <Process.h>
#include <SoftwareSerial.h>
Process p;
SoftwareSerial ss(8, 4);
void setup() {
// Comment this line out and everything works grand!
ss.begin(4800);
Bridge.begin();
Serial.begin(9600);
while (!Serial);
Serial.print("begin!");
}
void loop() {
// Delay whilst receiving data from the software serial. Approx 5 second between updates with curl delay.
delay(1000);
p.runShellCommandAsynchronously("ping -c 1 74.125.230.159");
while(p.running());
while(p.available()) {
Serial.print((char)p.read());
}
int exitValue = p.exitValue();
Serial.print(", Exit: " + String(exitValue));
}