ESP8266在Alios-Things上的入門開發指南 (二)ESP8266開啟CLI功能及添加CLI函數__函數

來源:互聯網
上載者:User

    Alios-Things支援幾種調試方式,具體作用及使用可參考連結地址

https://github.com/alibaba/AliOS-Things/wiki/Debugging-Overview.zh

    今天我們主要關注CLI調試的開啟,及增加CLI函數。

     1、修改entry.c代碼中 kinit 變數的cli_ebable的值為1

static kinit_t kinit = {    .argc = 0,    .argv = NULL,    .cli_enable = 1};

       “entry.c”檔案位於 "xxx\AliOS-Things\platform\mcu\esp8266\bsp"。

    2、在項目中添加CLI函數

        在此,我使用Example的 netmgrapp 的這個項目代碼為例子.

        開啟"netmgrapp.c"檔案的修ncmds結構數組及添加代碼如下所示

static void handle_jack_cmd(char *pwbuf, int blen, int argc, char **argv){    aos_cli_printf("Call me Jack,please\r\n");}static struct cli_command ncmds[] = {    {        .name = "test",        .help = "test",        .function = handle_test_cmd    },    {        .name = "jack",        .help = "jack",        .function = handle_jack_cmd    },#ifdef TEST_WIFI_HAL_ONLY    {        .name = "test_wifi_hal",        .help = "test_wifi_hal [start|scan|scan_adv|monitor [mngt]|80211send|get_mac|ip_info|all]",        .function = handle_test_wifi_cmd    }#endif};

    儲存後,在docker的編譯環境中執行如下指令

aos make netmgrapp@esp8266

    將產生的 netmgrapp@esp8266-0x1000.bin 檔案燒錄到開發板運行。

    3、使用串口工具運行CLI命令

     在串口工具中發送 help 指令到MCU進入CLI。從CLI返回的參數中我們可以看到我們剛剛添加的一條指令 "jack".
     接著我們通過串口工具發送 jack 指令到MCU,可以看到我們添加的列印資訊 :“Call me Jack,please”

運行結果如下圖所示


    自此,你可以自己添加CLI函數,用以調試開發產品功能.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.