Explorar el Código

[finsh] Clear buffer before switching to new shell device

ardafu hace 10 años
padre
commit
084a8dcd0c
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      components/finsh/shell.c

+ 5 - 1
components/finsh/shell.c

@@ -122,7 +122,11 @@ void finsh_set_device(const char* device_name)
             rt_device_close(shell->device);
             rt_device_set_rx_indicate(shell->device, RT_NULL);
         }
-
+        
+        /* clear line buffer before switch to new device */
+        memset(shell->line, 0, sizeof(shell->line));
+        shell->line_curpos = shell->line_position = 0;
+    
         shell->device = dev;
         rt_device_set_rx_indicate(dev, finsh_rx_ind);
     }