Skip to content

Commit 253b98c

Browse files
ESurgeskotopes
andauthored
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>
1 parent 16e598b commit 253b98c

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

applications/cli/cli.c

+10-8
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,23 @@ size_t cli_read_timeout(Cli* cli, uint8_t* buffer, size_t size, uint32_t timeout
6969
}
7070
}
7171

72-
bool cli_cmd_interrupt_received(Cli* cli) {
72+
bool cli_is_connected(Cli* cli) {
7373
furi_assert(cli);
74-
char c = '\0';
7574
if(cli->session != NULL) {
76-
if(cli->session->rx((uint8_t*)&c, 1, 0) == 1) {
77-
return c == CliSymbolAsciiETX;
78-
}
75+
return (cli->session->is_connected());
7976
}
8077
return false;
8178
}
8279

83-
bool cli_is_connected(Cli* cli) {
80+
bool cli_cmd_interrupt_received(Cli* cli) {
8481
furi_assert(cli);
85-
if(cli->session != NULL) {
86-
return (cli->session->is_connected());
82+
char c = '\0';
83+
if(cli_is_connected(cli)) {
84+
if(cli->session->rx((uint8_t*)&c, 1, 0) == 1) {
85+
return c == CliSymbolAsciiETX;
86+
}
87+
} else {
88+
return true;
8789
}
8890
return false;
8991
}

applications/subghz/subghz_cli.c

+5
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,11 @@ static void subghz_cli_command_chat(Cli* cli, string_t args) {
676676
break;
677677
}
678678
}
679+
if(cli_is_connected(cli)) {
680+
printf("\r\n");
681+
chat_event.event = SubGhzChatEventUserExit;
682+
subghz_chat_worker_put_event_chat(subghz_chat, &chat_event);
683+
}
679684
}
680685

681686
string_clear(input);

0 commit comments

Comments
 (0)