CLI: Fix long delay with quick connect/disconnect

noticeable with qflipper, for some reason it sets DTR on/off/on again
so flipper starts CLI, stops it, then starts again
but cli shell is trying to print motd, and pipe is already broken
so each character of motd times out for 100ms
changing pipe timeout to 10ms works too, but is just a workaround

it didnt always happen, i think that variable time of loading ext cmds
made it so on ofw it usually manages to print motd before pipe is broken
on cfw with more ext commands it always hung, on ofw only sometimes

important part is bailing early in cli shell
in cli vcp i made it cleanup cli shell on disconnect so it doesnt stay
around after disconnecting usb, might free a little ram maybe
This commit is contained in:
WillyJL
2025-07-22 17:10:41 +02:00
parent d1c3b0bc68
commit 291ed9d1ed
2 changed files with 10 additions and 9 deletions

View File

@@ -423,11 +423,16 @@ static int32_t cli_shell_thread(void* context) {
cli_shell_init(shell);
FURI_LOG_D(TAG, "Started");
if(pipe_state(shell->pipe) == PipeStateBroken) goto bail;
shell->motd(shell->callback_context);
cli_shell_line_prompt(shell->components[CliShellComponentLine]);
if(pipe_state(shell->pipe) == PipeStateBroken) goto bail;
furi_event_loop_run(shell->event_loop);
bail:
FURI_LOG_D(TAG, "Stopped");
cli_shell_deinit(shell);
return 0;