USB Serial blocking
Posted: Tue Aug 25, 2015 5:30 pm
I am new to ChibiOS and am using it with lwIP over Ethernet. The code generally works, but for debugging, I added some chsnprintf() statements to display status on the USB serial shell each time I transmit a lwIP packet. I've noticed that if an active USB serial shell connection is not present, the Ethernet activity eventually stops. I suspect that chsnprintf() fills the USB serial output buffer and then blocks the thread. Can someone more experienced provide any guidance? Is there a recommended way to handle generic debug text output in ChibiOS?
The relevant code snippet is below:
Many thanks!
The relevant code snippet is below:
Code: Select all
usb_serial_init();
shellInit();
chThdCreateStatic(wa_lwip_thread, LWIP_THREAD_STACK_SIZE, NORMALPRIO + 2,
lwip_thread, NULL);
while (TRUE) {
WATCHDOG_RELOAD;
if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE)) {
shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
debugChP = (BaseSequentialStream *)&SDU1;
} else if (chThdTerminated(shelltp)) {
chThdRelease(shelltp); /* Recovers memory of the previous shell. */
shelltp = NULL; /* Triggers spawning of a new shell. */
debugChP = NULL;
}
...
if (debugChP) {
chprintf(debugChP, report_buf);
}
send_report(&server_ip, report_buf, strlen(report_buf));
...
} // forever
Many thanks!