I've implemented this change to shell.c for an SDU use case where status output is directed to SDU.
Output to SDU is paused when a shell session is requested (by hitting a key on terminal).
After shell commands, etc. are finished the shell is normally terminated by 'exit' or ^D by the user.
However, when an SDU disconnect event happens due to USB SUSPEND then the shell can be programmatically terminated.
Code: Select all
Index: shell.c
===================================================================
--- shell.c (revision 11940)
+++ shell.c (working copy)
@@ -354,7 +354,7 @@
chprintf(chp, SHELL_NEWLINE_STR);
chprintf(chp, "ChibiOS/RT Shell" SHELL_NEWLINE_STR);
- while (true) {
+ while (!chThdShouldTerminateX()) {
chprintf(chp, SHELL_PROMPT_STR);
if (shellGetLine(scfg, line, sizeof(line), shp)) {
#if (SHELL_CMD_EXIT_ENABLED == TRUE) && !defined(_CHIBIOS_NIL_)