Call of Serial.print before Serial.begin gives a white breathing LED

Hi,
I did something dum today, look at this code:

webserver t = webserver(&fs);

void setup() {
Serial1.begin(57600);

What I did was calling Serial.print in the constructor of the webserver class before Serial1.begin was called. Result: white breathing led.
How did the bug came to existance? I changed the type of t from a class webserver*, that was initialized after Serial.begin was called to a globally declared class of which the constructor was called before setup() was called. duhh.

previous code:
webserver t = webserver(&fs);

void setup() {
Serial1.begin(57600);
t = new webserver(&fs);

Hi @marcus,

Ooh, good bug! I think that was squashed for just “Serial”, and I’m surprised it didn’t apply to "Serial1``` as well. I’ll post a bug for that here:

Thanks,
David

2 Likes

Thanks for your reaction! It took only 2 hours of my life, well spend poking around in the spark classes! So no sweat!

regards,
Marcus

2 Likes

Is this issue fixed in spark.cli version for Serial (not Serial1)?
I have breathing white issue when i enable some debug and start printing in serial in setup()

Hi,
The bug I described, is not really a bug, but a program error, one must call Serial[x].begin() before using the serial port.
The behaviour of the Core is only a bit ambigious when you forget to do it right, it signals a breathing white, that means something else… see: https://community.spark.io/t/what-do-the-colors-on-the-spark-core-led-mean/533

regards,
marcus