Added condition to cli "log" command to end if serial terminal is disconnected. (#1425)
* Added condition to cli "log" command. If USB is disconnected while "log" command is running, it will end the command. * Reverted change on cli_commands.c Added condition in cli.c for cli_cmd_interrupt_received function to react appropriately when serial terminal is disconnected. Added condition in subghz_cli.c for subghz chat cmd to exit gracefully when serial terminal is disconnected. * Formatting Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
16e598b2c0
commit
253b98c8f0
@ -69,17 +69,6 @@ size_t cli_read_timeout(Cli* cli, uint8_t* buffer, size_t size, uint32_t timeout
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cli_cmd_interrupt_received(Cli* cli) {
|
|
||||||
furi_assert(cli);
|
|
||||||
char c = '\0';
|
|
||||||
if(cli->session != NULL) {
|
|
||||||
if(cli->session->rx((uint8_t*)&c, 1, 0) == 1) {
|
|
||||||
return c == CliSymbolAsciiETX;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cli_is_connected(Cli* cli) {
|
bool cli_is_connected(Cli* cli) {
|
||||||
furi_assert(cli);
|
furi_assert(cli);
|
||||||
if(cli->session != NULL) {
|
if(cli->session != NULL) {
|
||||||
@ -88,6 +77,19 @@ bool cli_is_connected(Cli* cli) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cli_cmd_interrupt_received(Cli* cli) {
|
||||||
|
furi_assert(cli);
|
||||||
|
char c = '\0';
|
||||||
|
if(cli_is_connected(cli)) {
|
||||||
|
if(cli->session->rx((uint8_t*)&c, 1, 0) == 1) {
|
||||||
|
return c == CliSymbolAsciiETX;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void cli_print_usage(const char* cmd, const char* usage, const char* arg) {
|
void cli_print_usage(const char* cmd, const char* usage, const char* arg) {
|
||||||
furi_assert(cmd);
|
furi_assert(cmd);
|
||||||
furi_assert(arg);
|
furi_assert(arg);
|
||||||
|
@ -676,6 +676,11 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(cli_is_connected(cli)) {
|
||||||
|
printf("\r\n");
|
||||||
|
chat_event.event = SubGhzChatEventUserExit;
|
||||||
|
subghz_chat_worker_put_event_chat(subghz_chat, &chat_event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string_clear(input);
|
string_clear(input);
|
||||||
|
Loading…
Reference in New Issue
Block a user