P2 USB Serial is very slow compared to Photon

Hi @rickkas7

I was wondering if there has been any updates on this issue?

Comparing the serial output between Photon 2 and Photon 1, I still get a > 20 fold slow down in Photon 2 vs 1 with > 5ms compared to ~250 µs (details below) for a log message. I'm assuming this is still the same buffer issues you explained in this thread and was hoping there might be a way for solving this more generally, Or if not, could you kindly point out a good way to use your solution with the SerialLogHandler (recommend instead of Serial in the particle docs)? Note on context: running a stepper motor at a range of speeds up to pretty fast rates (requiring ~1 step / ms) which used to be no problem but now the Serial debug messages cause the stepper to skip.

Thank you for all your help!

Photon 2 (firmware v. 5.6.0):

0000010907 [app] INFO: log message took 5563 microseconds
0000011913 [app] INFO: log message took 5723 microseconds
0000012918 [app] INFO: log message took 5370 microseconds
0000013924 [app] INFO: log message took 5310 microseconds
0000014929 [app] INFO: log message took 5520 microseconds

Photon 1 (firmware v. 2.3.1):

0000008089 [app] INFO: log message took 220 microseconds
0000009090 [app] INFO: log message took 225 microseconds
0000010090 [app] INFO: log message took 220 microseconds
0000011090 [app] INFO: log message took 261 microseconds
0000012090 [app] INFO: log message took 220 microseconds

Generated with this slightly adapted version of your code:

#include "Particle.h"

SYSTEM_THREAD(ENABLED);

SerialLogHandler logHandler;

void setup() {

}

void loop() {
    static unsigned long lastRun = 0;
    unsigned long start = micros();
    Log.info("log message took %lu microseconds", lastRun);
    lastRun = micros() - start;
    delay(1000);
}