Просмотр исходного кода

Fix for new `furi_thread_set_stdout_callback()`

Willy-JL 1 год назад
Родитель
Сommit
cc24afcb6d
3 измененных файлов с 12 добавлено и 9 удалено
  1. 6 5
      cli_bridge/cli_control.c
  2. 4 3
      mp_flipper/upython.c
  3. 2 1
      mp_flipper/upython_cli.c

+ 6 - 5
cli_bridge/cli_control.c

@@ -16,7 +16,8 @@ static void tx_handler(const uint8_t* buffer, size_t size) {
     furi_stream_buffer_send(cli_tx_stream, buffer, size, FuriWaitForever);
 }
 
-static void tx_handler_stdout(const char* buffer, size_t size) {
+static void tx_handler_stdout(const char* buffer, size_t size, void* context) {
+    UNUSED(context);
     tx_handler((const uint8_t*)buffer, size);
 }
 
@@ -32,9 +33,9 @@ static size_t real_rx_handler(uint8_t* buffer, size_t size, uint32_t timeout) {
         rx_cnt += len;
     }
     if(restore_tx_stdout) {
-        furi_thread_set_stdout_callback(cli_vcp.tx_stdout);
+        furi_thread_set_stdout_callback(cli_vcp.tx_stdout, NULL);
     } else {
-        furi_thread_set_stdout_callback(tx_handler_stdout);
+        furi_thread_set_stdout_callback(tx_handler_stdout, NULL);
     }
     return rx_cnt;
 }
@@ -87,7 +88,7 @@ void clicontrol_hijack(size_t tx_size, size_t rx_size) {
     cli_session_close(global_cli);
     restore_tx_stdout = false;
     cli_session_open(global_cli, session);
-    furi_thread_set_stdout_callback(prev_stdout);
+    furi_thread_set_stdout_callback(prev_stdout, NULL);
 
     furi_record_close(RECORD_CLI);
 }
@@ -134,7 +135,7 @@ void clicontrol_unhijack(bool persist) {
     FuriThreadStdoutWriteCallback prev_stdout = furi_thread_get_stdout_callback();
     cli_session_close(global_cli);
     cli_session_open(global_cli, &cli_vcp);
-    furi_thread_set_stdout_callback(prev_stdout);
+    furi_thread_set_stdout_callback(prev_stdout, NULL);
     furi_record_close(RECORD_CLI);
 
     // Unblock waiting rx handler, restore old cli_vcp.tx_stdout

+ 4 - 3
mp_flipper/upython.c

@@ -10,7 +10,8 @@ volatile Action action = ActionNone;
 FuriString* file_path = NULL;
 volatile FuriThreadStdoutWriteCallback stdout_callback = NULL;
 
-static void write_to_log_output(const char* data, size_t size) {
+static void write_to_log_output(const char* data, size_t size, void* context) {
+    UNUSED(context);
     furi_log_tx((const uint8_t*)data, size);
 }
 
@@ -41,7 +42,7 @@ int32_t upython(void* args) {
         case ActionRepl:
             break;
         case ActionExec:
-            furi_thread_set_stdout_callback(stdout_callback);
+            furi_thread_set_stdout_callback(stdout_callback, NULL);
 
             upython_file_execute(file_path);
 
@@ -49,7 +50,7 @@ int32_t upython(void* args) {
 
             action = ActionNone;
 
-            furi_thread_set_stdout_callback(stdout_callback = NULL);
+            furi_thread_set_stdout_callback(stdout_callback = NULL, NULL);
 
             break;
         case ActionExit:

+ 2 - 1
mp_flipper/upython_cli.c

@@ -5,7 +5,8 @@
 
 static FuriStreamBuffer* stdout_buffer = NULL;
 
-static void write_to_stdout_buffer(const char* data, size_t size) {
+static void write_to_stdout_buffer(const char* data, size_t size, void* context) {
+    UNUSED(context);
     furi_stream_buffer_send(stdout_buffer, data, size, 0);
 }