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:
ESurge 2022-07-22 20:35:14 -07:00 committed by GitHub
parent 16e598b2c0
commit 253b98c8f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 11 deletions

View File

@ -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) {
furi_assert(cli);
if(cli->session != NULL) {
@ -88,6 +77,19 @@ bool cli_is_connected(Cli* cli) {
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) {
furi_assert(cmd);
furi_assert(arg);

View File

@ -676,6 +676,11 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
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);