3232 * 2022-07-02 Stanley Lwin add list command
3333 * 2023-09-15 xqyjlj perf rt_hw_interrupt_disable/enable
3434 * 2024-02-09 Bernard fix the version command
35+ * 2023-02-25 GuEe-GUI add console
3536 */
3637
3738#include <rthw.h>
4041
4142#ifdef RT_USING_FINSH
4243#include <finsh.h>
44+ #include <posix/stdio.h>
4345
4446#define LIST_DFS_OPT_ID 0x100
4547#define LIST_FIND_OBJ_NR 8
@@ -60,6 +62,48 @@ static long version(void)
6062}
6163MSH_CMD_EXPORT (version , show RT - Thread version information );
6264
65+ static int console (int argc , char * * argv )
66+ {
67+ rt_err_t result = RT_EOK ;
68+
69+ if (argc > 1 )
70+ {
71+ if (!rt_strcmp (argv [1 ], "set" ))
72+ {
73+ rt_kprintf ("console change to %s\n" , argv [2 ]);
74+ rt_console_set_device (argv [2 ]);
75+
76+ #ifdef RT_USING_POSIX
77+ {
78+ rt_device_t dev = rt_device_find (argv [2 ]);
79+
80+ if (dev != RT_NULL )
81+ {
82+ console_set_iodev (dev );
83+ }
84+ }
85+ #elif !defined(RT_USING_POSIX_STDIO )
86+ finsh_set_device (argv [2 ]);
87+ #else
88+ rt_posix_stdio_init ();
89+ #endif /* RT_USING_POSIX */
90+ }
91+ else
92+ {
93+ rt_kprintf ("Unknown command. Please enter 'console' for help\n" );
94+ result = - RT_ERROR ;
95+ }
96+ }
97+ else
98+ {
99+ rt_kprintf ("Usage: \n" );
100+ rt_kprintf ("console set <name> - change console by name\n" );
101+ result = - RT_ERROR ;
102+ }
103+ return result ;
104+ }
105+ MSH_CMD_EXPORT (console , console setting );
106+
63107rt_inline void object_split (int len )
64108{
65109 while (len -- ) rt_kprintf ("-" );
0 commit comments