[RTT例程练习] 6.3 在 Finsh 中查看自定义变量
和前面类似,使用宏,就可以将变量输出至Finsh
FINSH_VAR_EXPORT(count, finsh_type_int, count variable for finsh);
程序
#include <rtthread.h> #include <finsh.h> static rt_thread_t tid = RT_NULL; static void thread_entry(void *parameter) { while (1) { rt_thread_delay(1000); } } static rt_uint32_t count = 34; FINSH_VAR_EXPORT(count, finsh_type_int, count variable for finsh); int rt_application_init() { tid = rt_thread_create("tid", thread_entry, RT_NULL, 1024, 8, 50); if (tid != RT_NULL) rt_thread_startup(tid); return 0; }
结果
SystemInit...... \ | / - RT - Thread Operating System / | \ 1.0.1 build Apr 7 2013 2006 - 2011 Copyright by rt-thread team finsh>>list() --Function List: list_mem -- list memory usage information hello -- say hello world version -- show RT-Thread version information list_thread -- list thread list_sem -- list semaphone in system list_event -- list event in system list_mutex -- list mutex in system list_mailbox -- list mail box in system list_msgqueue -- list message queue in system list_mempool -- list memory pool in system list_timer -- list timer in system list_device -- list device in system list -- list all symbol in system --Variable List: dummy -- dummy variable for finsh count -- count variable for finsh 0, 0x00000000 finsh>>count '"', 34, 0x00000022
可以看到,变量输出的值和程序初始化的一样。