Skip to content

Commit

Permalink
Added condition to cli "log" command to end if serial terminal is dis…
Browse files Browse the repository at this point in the history
…connected. (#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>
  • Loading branch information
ESurge and skotopes authored Jul 23, 2022
1 parent 16e598b commit 253b98c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
18 changes: 10 additions & 8 deletions applications/cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,23 @@ size_t cli_read_timeout(Cli* cli, uint8_t* buffer, size_t size, uint32_t timeout
}
}

bool cli_cmd_interrupt_received(Cli* cli) {
bool cli_is_connected(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 (cli->session->is_connected());
}
return false;
}

bool cli_is_connected(Cli* cli) {
bool cli_cmd_interrupt_received(Cli* cli) {
furi_assert(cli);
if(cli->session != NULL) {
return (cli->session->is_connected());
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;
}
Expand Down
5 changes: 5 additions & 0 deletions applications/subghz/subghz_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 253b98c

Please sign in to comment.