mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-10 20:35:54 +00:00
fixup! refactor(core/prodtest): make cli non-blocking, event-loop compatible
This commit is contained in:
parent
3387a4ab40
commit
b371169dc9
@ -541,6 +541,11 @@ bool cli_get_event(cli_t* cli, cli_event_t* event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cli->cmd_active) {
|
||||
// Some command is already active or waiting for processing
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the next line
|
||||
int res = cli_process_char(cli);
|
||||
|
||||
@ -599,8 +604,7 @@ bool cli_get_event(cli_t* cli, cli_event_t* event) {
|
||||
|
||||
event->type = CLI_EVENT_COMMAND_RECEIVED;
|
||||
event->data.command_received.command = cmd;
|
||||
|
||||
cli_clear_line(cli);
|
||||
cli->cmd_active = true;
|
||||
return true;
|
||||
|
||||
cleanup:
|
||||
@ -632,6 +636,9 @@ void cli_process_command(cli_t* cli, const cli_command_t* cmd) {
|
||||
// Print the prompt
|
||||
cli_printf(cli, "> ");
|
||||
}
|
||||
|
||||
cli->cmd_active = false;
|
||||
cli_clear_line(cli);
|
||||
}
|
||||
|
||||
// Return position of the argument with the given name in
|
||||
|
@ -98,6 +98,9 @@ struct cli {
|
||||
int hist_idx;
|
||||
int hist_prefix;
|
||||
|
||||
// Command active flag
|
||||
bool cmd_active; // true if the command is pending or being processed
|
||||
|
||||
// Command name (pointer to the line buffer)
|
||||
const char* cmd_name;
|
||||
// Number of parsed arguments
|
||||
|
Loading…
Reference in New Issue
Block a user