I'm using ChibiOS 21.11 on an STM32L496.
I'm using the serial_usb module to create a virtual com port over USB.
This virtual com port is used as the BaseSequentialStream for the shell.
When a certain command is entered the serial USB device is disabled and the USB is used for a mass storage device.
Let's call this command 'do_switch_msd'.
When the MSD is ejected the serial USB device is started again.
I noticed that when the USB device is disabled, the shell executes the 'do_switch_msd' command is called again.
After closer inspection I've noticed that:
- When shellGetLine fails (due to the stream being closed), and
- SHELL_CMD_EXIT_ENABLED is FALSE
Here's a diff of how I'd solve this issue:
Code: Select all
diff --git a/os/various/shell/shell.c b/os/various/shell/shell.c
index a7cd30849..62594223f 100644
--- a/os/various/shell/shell.c
+++ b/os/various/shell/shell.c
@@ -375,6 +375,7 @@ THD_FUNCTION(shellThread, p) {
/* Putting a delay in order to avoid an endless loop trying to read
an unavailable stream.*/
osalThreadSleepMilliseconds(100);
+ continue;
#endif
}
lp = parse_arguments(line, &tokp);
I don't know if anyone or anything is counting on this behavior, but I consider this a bug.
Cheers