/* This function sets the input device of finsh shell. */
void finsh_set_device(const char *device_name)
/* This function sets the input device of finsh shell. */
void finsh_set_device(const char *device_name)
{
    rt_device_t dev = RT_NULL;
    RT_ASSERT(shell != RT_NULL);
    dev = rt_device_find(device_name);
    if (dev == RT_NULL)
    {
        rt_kprintf("finsh: can not find device: %s\n", device_name);
        return;
    }
    if (dev == shell->device) return;
    if (rt_device_open(dev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX) == RT_EOK)
    {
        if (shell->device != RT_NULL)
        {
            rt_device_close(shell->device);
            rt_device_set_rx_indicate(dev, RT_NULL);
        }
        shell->device = dev;
        rt_device_set_rx_indicate(dev, finsh_rx_ind);
    }
}