Logger class and SOS

I would like to utilize the logger class, but I am running into a lot of stability issues when I use it. Here is an example that will trigger an SOS crash every time. This is reproduced on Proton and Duo.

The example below using the ArduinoJson library is just one example. There are other situations that the logger will cause an SOS crash. This example just seemed pretty straight forward and not clear why an error would occur.

SOS code is Stack Overflow.

Any ideas?

#include <ArduinoJson.h>

SerialLogHandler logHandler(115200);
Logger appLogger("app"); 

SYSTEM_MODE(AUTOMATIC);

Timer periodicTimer(5000, worker);

 void setup() {

    appLogger("Hello");

   periodicTimer.start();

}

void worker() {

  appLogger("Later");

  //Serial.println("Later");

  StaticJsonBuffer<200> jsonBuffer;
  JsonObject& collectorAttributes = jsonBuffer.createObject();

}

void loop() {

}

Iā€™d guess the stack for software timers is too small for the use of AdafruitJson inside the timer callback.

Also the parameter for SerialLogHandler does not take the baudrate but the log level.
Baudrate is for Serial1LogHandler

1 Like

Ah, yes timers have a smaller stack. I forgot about that. Easy fix. Thanks.

1 Like