diff --git a/components/finsh/shell.c b/components/finsh/shell.c index f28e235b3fed8ffb4c1e5bbc6c9577df817bd9e4..c4708cee111f7e12b7f937762eb92c69a3c63b46 100644 --- a/components/finsh/shell.c +++ b/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); }