From 084a8dcd0c879f772672210e3d9674624a723015 Mon Sep 17 00:00:00 2001 From: ardafu Date: Fri, 22 May 2015 16:35:01 +0800 Subject: [PATCH] [finsh] Clear buffer before switching to new shell device --- components/finsh/shell.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/finsh/shell.c b/components/finsh/shell.c index f28e235b3f..c4708cee11 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); }