|
|
@@ -3,6 +3,7 @@
|
|
|
#include <cli/cli.h>
|
|
|
#include <cli/cli_i.h>
|
|
|
#include <cli/cli_vcp.h>
|
|
|
+#include <furi/core/thread_i.h>
|
|
|
#include "cligui_main_i.h"
|
|
|
#include <FreeRTOS.h>
|
|
|
|
|
|
@@ -34,11 +35,10 @@ static size_t real_rx_handler(uint8_t* buffer, size_t size, uint32_t timeout) {
|
|
|
return rx_cnt;
|
|
|
}
|
|
|
|
|
|
-static CliCommand_internal* getInternalCliCommand(Cli* cli, const char* name) {
|
|
|
+static CliCommand* getCliCommand(Cli* cli, const char* name) {
|
|
|
FuriString* target_command = furi_string_alloc();
|
|
|
furi_string_set_str(target_command, name);
|
|
|
- CliCommand_internal* command =
|
|
|
- CliCommandTree_internal_get(((Cli_internal*)cli)->commands, target_command);
|
|
|
+ CliCommand* command = CliCommandTree_get(cli->commands, target_command);
|
|
|
furi_string_free(target_command);
|
|
|
return command;
|
|
|
}
|
|
|
@@ -54,12 +54,12 @@ static CliSession session;
|
|
|
void latch_tx_handler() {
|
|
|
Cli* global_cli = furi_record_open(RECORD_CLI);
|
|
|
|
|
|
- CliCommand_internal* help_command = getInternalCliCommand(global_cli, "help");
|
|
|
+ CliCommand* help_command = getCliCommand(global_cli, "help");
|
|
|
cliThread = help_command->context;
|
|
|
|
|
|
furi_thread_set_stdout_callback(tx_handler_stdout);
|
|
|
if(cliThread != NULL) {
|
|
|
- ((FuriThread_internal*)cliThread)->output.write_callback = &tx_handler_stdout;
|
|
|
+ cliThread->output.write_callback = &tx_handler_stdout;
|
|
|
}
|
|
|
|
|
|
rx_stream = furi_stream_buffer_alloc(128, 1);
|
|
|
@@ -75,9 +75,8 @@ void latch_tx_handler() {
|
|
|
cli_session_open(global_cli, &session);
|
|
|
// Unlock loader-lock
|
|
|
Loader* loader = furi_record_open(RECORD_LOADER);
|
|
|
- Loader_internal* loader_i = (Loader_internal*)loader;
|
|
|
- prev_appthread = loader_i->app.thread;
|
|
|
- loader_i->app.thread = NULL;
|
|
|
+ prev_appthread = loader->app.thread;
|
|
|
+ loader->app.thread = NULL;
|
|
|
furi_record_close(RECORD_LOADER);
|
|
|
furi_record_close(RECORD_CLI);
|
|
|
}
|
|
|
@@ -85,7 +84,7 @@ void unlatch_tx_handler(bool persist) {
|
|
|
Cli* global_cli = furi_record_open(RECORD_CLI);
|
|
|
// Stash cliThread if not null
|
|
|
if(cliThread != NULL) {
|
|
|
- CliCommand_internal* help_command = getInternalCliCommand(global_cli, "help");
|
|
|
+ CliCommand* help_command = getCliCommand(global_cli, "help");
|
|
|
help_command->context = cliThread;
|
|
|
}
|
|
|
// Switch to new session
|
|
|
@@ -103,14 +102,13 @@ void unlatch_tx_handler(bool persist) {
|
|
|
furi_stream_buffer_send(rx_stream, "_", 1, FuriWaitForever);
|
|
|
// Reconfigure stdout_callback to cli_vcp
|
|
|
if(cliThread != NULL) {
|
|
|
- ((FuriThread_internal*)cliThread)->output.write_callback = cli_vcp.tx_stdout;
|
|
|
+ cliThread->output.write_callback = cli_vcp.tx_stdout;
|
|
|
}
|
|
|
// At this point, all cli_vcp functions should be back.
|
|
|
furi_stream_buffer_free(rx_stream);
|
|
|
furi_stream_buffer_free(tx_stream);
|
|
|
// Re-lock loader (to avoid crash on automatic unlock)
|
|
|
Loader* loader = furi_record_open(RECORD_LOADER);
|
|
|
- Loader_internal* loader_i = (Loader_internal*)loader;
|
|
|
- loader_i->app.thread = prev_appthread;
|
|
|
+ loader->app.thread = prev_appthread;
|
|
|
furi_record_close(RECORD_LOADER);
|
|
|
}
|