1 控制台线程在文件 rt-thread/components/finsh/shell.c 中,线程的入口函数是 finsh_thread_entry,如果想改为 RS485 的就需要在里面修改,改起来还是有一些麻烦的,建议板子上预留一个普通串口做控制台。
- void finsh_thread_entry(void *parameter)
- {
- int ch;
- /* normal is echo mode */
- #ifndef FINSH_ECHO_DISABLE_DEFAULT
- shell->echo_mode = 1;
- #else
- shell->echo_mode = 0;
- #endif
- #ifndef FINSH_USING_MSH_ONLY
- finsh_init(&shell->parser);
- #endif
- #if !defined(RT_USING_POSIX) && defined(RT_USING_DEVICE)
- /* set console device as shell device */
- if (shell->device == RT_NULL)
- {
- rt_device_t console = rt_console_get_device();
- if (console)
- {
- finsh_set_device(console->parent.name);
- }
- }
- #endif
2 控制行输入的命令示例如下:比如 rs485 create uart3 9600 0 1 1
- static const char *cmd_info[] =
- {
- "Usage: n",
- "rs485 create [serial] [baudrate] [parity] [pin] [level] - create rs485 instance.n",
- "rs485 destory - destory rs485 instance.n",
- "rs485 set_recv_tmo [tmo_ms] - set recieve timeout.n",
- "rs485 set_byte_tmo [tmo_ms] - set byte timeout.n",
- "rs485 connect - open rs485 connect.n",
- "rs485 disconn - close rs485 connect.n",
- "rs485 recv [size] - receive from rs485.n",
- "rs485 send [size] - send to rs485.n",
- "rs485 cfg [baudrate] [databits] [parity] [stopbits] - config rs485.n",
- "rs485 send_then_recv [send_size] [recv_size] - send to rs485 and then receive from rs485.n",
- "n"
- };
1 控制台线程在文件 rt-thread/components/finsh/shell.c 中,线程的入口函数是 finsh_thread_entry,如果想改为 RS485 的就需要在里面修改,改起来还是有一些麻烦的,建议板子上预留一个普通串口做控制台。
- void finsh_thread_entry(void *parameter)
- {
- int ch;
- /* normal is echo mode */
- #ifndef FINSH_ECHO_DISABLE_DEFAULT
- shell->echo_mode = 1;
- #else
- shell->echo_mode = 0;
- #endif
- #ifndef FINSH_USING_MSH_ONLY
- finsh_init(&shell->parser);
- #endif
- #if !defined(RT_USING_POSIX) && defined(RT_USING_DEVICE)
- /* set console device as shell device */
- if (shell->device == RT_NULL)
- {
- rt_device_t console = rt_console_get_device();
- if (console)
- {
- finsh_set_device(console->parent.name);
- }
- }
- #endif
2 控制行输入的命令示例如下:比如 rs485 create uart3 9600 0 1 1
- static const char *cmd_info[] =
- {
- "Usage: n",
- "rs485 create [serial] [baudrate] [parity] [pin] [level] - create rs485 instance.n",
- "rs485 destory - destory rs485 instance.n",
- "rs485 set_recv_tmo [tmo_ms] - set recieve timeout.n",
- "rs485 set_byte_tmo [tmo_ms] - set byte timeout.n",
- "rs485 connect - open rs485 connect.n",
- "rs485 disconn - close rs485 connect.n",
- "rs485 recv [size] - receive from rs485.n",
- "rs485 send [size] - send to rs485.n",
- "rs485 cfg [baudrate] [databits] [parity] [stopbits] - config rs485.n",
- "rs485 send_then_recv [send_size] [recv_size] - send to rs485 and then receive from rs485.n",
- "n"
- };
举报