While (!Serial.available()) does not appear to work with 0.8.0-RC.27

I am debugging a Mesh comms only Xenon end node, I have it plugged in and powered via USB serial.

When I inserted in setup()

Serial.begin(115200);
while(!Serial.available()) delay(10);

To wait for serial terminal input before continuing setup() it just stopped and did not continue once - searched for an error posting but can't find one for this issue. Am I missing something?

What terminal program are you using to send data to the device?

I think I know what you are going to say - is this some DTR issue with the terminal software?

SerialTools on a Mac

Edit: I just ticked DTR and CTS and things started to appear. Not required with the Photon, etc.

2 Likes

Are you sure your code is running?
I’ve read in the other thread you were investigating MANUAL mode.
I’ve tried this and I never actually see the output on my terminal

SYSTEM_MODE(MANUAL)
SYSTEM_THREAD(ENABLED)


void setup() {
  Serial.begin(115200);
  pinMode(D7, OUTPUT);
  while(!Serial.available()) {
    Serial.print(".");
    delay(100);
  }
  digitalWrite(D7, HIGH);
}

void loop() {
}

So it could be that the line isn’t actually reached.


Update:
As it turns out the reason why it didn’t work for me was that my local build did not produce a correct binary :confused:

1 Like