zoukankan      html  css  js  c++  java
  • [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
    

    可以看到,变量输出的值和程序初始化的一样。

  • 相关阅读:
    企业生产环境不同业务linux系统分区方案
    linux 文件 s 权限
    shell中的命令与特殊符号
    Linux数组基础
    shell脚本学习(1)
    文件的压缩与打包
    Linux 磁盘管理基础命令df,du,fdisk,mke2fs
    mkpasswd的使用
    P1080 国王游戏
    P1315 观光公交
  • 原文地址:https://www.cnblogs.com/lyyyuna/p/4123911.html
Copyright © 2011-2022 走看看