MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / finsh_set_device

Function finsh_set_device

components/finsh/shell.c:219–251  ·  view source on GitHub ↗

* @ingroup group_finsh * * This function sets the input device of finsh shell. * * @param device_name the name of new input device. */

Source from the content-addressed store, hash-verified

217 * @param device_name the name of new input device.
218 */
219void finsh_set_device(const char *device_name)
220{
221 rt_device_t dev = RT_NULL;
222
223 RT_ASSERT(shell != RT_NULL);
224 dev = rt_device_find(device_name);
225 if (dev == RT_NULL)
226 {
227 rt_kprintf("finsh: can not find device: %s\n", device_name);
228 return;
229 }
230
231 /* check whether it's a same device */
232 if (dev == shell->device) return;
233 /* open this device and set the new device in finsh shell */
234 if (rt_device_open(dev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX | \
235 RT_DEVICE_FLAG_STREAM) == RT_EOK)
236 {
237 if (shell->device != RT_NULL)
238 {
239 /* close old finsh device */
240 rt_device_close(shell->device);
241 rt_device_set_rx_indicate(shell->device, RT_NULL);
242 }
243
244 /* clear line buffer before switch to new device */
245 rt_memset(shell->line, 0, sizeof(shell->line));
246 shell->line_curpos = shell->line_position = 0;
247
248 shell->device = dev;
249 rt_device_set_rx_indicate(dev, finsh_rx_ind);
250 }
251}
252
253/**
254 * @ingroup group_finsh

Callers 15

finsh_thread_entryFunction · 0.85
adb_enterFunction · 0.85
adb_exitFunction · 0.85
rt_init_thread_entryFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
rtthread_startupFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
rtthread_startupFunction · 0.85

Calls 6

rt_device_findFunction · 0.85
rt_kprintfFunction · 0.85
rt_device_openFunction · 0.85
rt_device_closeFunction · 0.85
rt_memsetFunction · 0.85

Tested by

no test coverage detected