Hi @rickkas7
I was wondering if there has been any more updates on this issue (slow USB serial on p2)? We solved the stepper issue so this is just about the serial itself. I was thinking that [gen4] hal: get rid of unnecessary constant delay(1) in HAL_USB_USART_Send_Data() by avtolstoy · Pull Request #2867 · particle-iot/device-os · GitHub might fix the slow serial on the P2 based on the discussion in Photon2 problems with Serial peripherals - #6 by rickkas7 but now realize that solution was for the UART and not for USB serial. Unfortunately the upgrade to the recently released firmware v. 6.3.2 actually makes this problem worse. Now a log message takes almost 20 ms on the p2 (instead of 0.2 ms on the P1).
If there's no fix planned in the firmware, could you advise on how to use your asynchronous serial approach (GitHub - rickkas7/AsyncUSBSerialRK: Asynchronous USB Serial (CDC) for the Particle P2 and Photon 2) with SerialLogHandler
? Any help/advice very much appreciated.
Here's the test code and results:
Serial speed test
#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);
}
Results
Photon 2 (firmware v. 6.3.2):
0000003403 [app] INFO: log message took 18371 microseconds
0000004421 [app] INFO: log message took 17878 microseconds
0000005439 [app] INFO: log message took 17685 microseconds
0000006458 [app] INFO: log message took 19206 microseconds
Photon 2 (firmware v. 5.6.0):
0000008451 [app] INFO: log message took 5264 microseconds
0000009457 [app] INFO: log message took 5220 microseconds
0000010462 [app] INFO: log message took 5471 microseconds
0000011468 [app] INFO: log message took 5545 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