Przeglądaj źródła

[FL-2493] Infrared: fix crash on invalid name. Input: cancel info in dump command. (#1153)

* Infrared: fix crash on invalid name. Input: cancel info in dump command.
* FuriHal: add abort handler
あく 3 lat temu
rodzic
commit
b28d408b49

+ 11 - 8
applications/infrared/infrared_app.cpp

@@ -14,14 +14,17 @@ int32_t InfraredApp::run(void* args) {
     if(args) {
         std::string path = static_cast<const char*>(args);
         std::string remote_name(path, path.find_last_of('/') + 1, path.size());
-        remote_name.erase(remote_name.find_last_of('.'));
-        path.erase(path.find_last_of('/'));
-        bool result = remote_manager.load(path, remote_name);
-        if(result) {
-            current_scene = InfraredApp::Scene::Remote;
-        } else {
-            printf("Failed to load remote \'%s\'\r\n", remote_name.c_str());
-            return -1;
+        auto last_dot = remote_name.find_last_of('.');
+        if(last_dot != std::string::npos) {
+            remote_name.erase(last_dot);
+            path.erase(path.find_last_of('/'));
+            bool result = remote_manager.load(path, remote_name);
+            if(result) {
+                current_scene = InfraredApp::Scene::Remote;
+            } else {
+                printf("Failed to load remote \'%s\'\r\n", remote_name.c_str());
+                return -1;
+            }
         }
     }
 

+ 2 - 6
applications/input/input_cli.c

@@ -24,19 +24,15 @@ static void input_cli_dump(Cli* cli, string_t args, Input* input) {
     FuriPubSubSubscription* input_subscription =
         furi_pubsub_subscribe(input->event_pubsub, input_cli_dump_events_callback, input_queue);
 
-    bool stop = false;
     InputEvent input_event;
-    while(!stop) {
+    printf("Press CTRL+C to stop\r\n");
+    while(!cli_cmd_interrupt_received(cli)) {
         if(osMessageQueueGet(input_queue, &input_event, NULL, 100) == osOK) {
             printf(
                 "key: %s type: %s\r\n",
                 input_get_key_name(input_event.key),
                 input_get_type_name(input_event.type));
         }
-
-        if(cli_cmd_interrupt_received(cli)) {
-            stop = true;
-        }
     }
 
     furi_pubsub_unsubscribe(input->event_pubsub, input_subscription);

+ 4 - 0
firmware/targets/f7/Src/main.c

@@ -65,6 +65,10 @@ void Error_Handler(void) {
     furi_crash("ErrorHandler");
 }
 
+void abort() {
+    furi_crash("AbortHandler");
+}
+
 #ifdef USE_FULL_ASSERT
 /**
     * @brief  Reports the name of the source file and the source line number