返回列表 发新帖我要提问本帖赏金: 100.00元(功能说明)

[方案相关] HC32F072之nr_micro_shell移植+源码

[复制链接]
28048|94
朝生 发表于 2023-7-18 13:22 | 显示全部楼层
可以经由过程uart,毗连到单片机装备,实现对于装备的长途调试以及节制。
wjc3k 发表于 2023-8-9 07:06 | 显示全部楼层
学习,学习,学习。
yangxiaor520 发表于 2023-8-9 08:09 来自手机 | 显示全部楼层
和littleshell相比,哪个更好用。
 楼主| caizhiwei 发表于 2023-8-9 15:36 | 显示全部楼层
yangxiaor520 发表于 2023-8-9 08:09
和littleshell相比,哪个更好用。

这种更简单一点更好用,自定义指令都是相通的
 楼主| caizhiwei 发表于 2023-8-9 15:38 | 显示全部楼层
分享一下我自己自定义的shell 指令:
  1. /*
  2. argc是参数的数目
  3. argv存储每个参数的起始地址和内容
  4. */
  5. void shell_reboot_cmd(char argc, char *argv)
  6. {
  7.     if (0 == strcmp("reboot", &argv[argv[0]]))
  8.     {
  9.         shell_printf("MCU Reboot now!!\r\n");
  10.         MCU_SW_reset();
  11.     }
  12. }


  13. /**
  14. * @brief iap command
  15. */
  16. void shell_update_cmd(char argc, char *argv)
  17. {
  18.         if (0 == strcmp("update", &argv[argv[0]]))
  19.     {
  20.         shell_printf("MCU Ready to OTA!!\r\n");
  21.                 UsrCMD.lte_update_cmd = true;
  22.     }
  23. }


  24. void shell_erase_cmd(char argc, char *argv)
  25. {
  26.         if (0 == strcmp("erase", &argv[argv[0]]))
  27.     {
  28.                 if (argc > 1)
  29.                 {
  30.                         if (0 == strcmp("disk0", &argv[argv[1]]))
  31.                         {
  32.                                 shell_printf("Erase (Inner Flash) Fatfs...\r\n");
  33.                                 //f_mount(NULL, "0:", 0);
  34.                                 BSP_fmc_erase_bank1();  // whole bank1       
  35.                         }
  36.                         if (0 == strcmp("disk1", &argv[argv[1]]))
  37.                         {
  38.                                 shell_printf("Erase (SPI Flash) Fatfs...\r\n");
  39.                                 //f_mount(NULL, "1:", 0);
  40.                                 spi_flash_bulk_erase(); // whole chip
  41.                         }
  42.                 }       
  43.     }
  44. }

  45. void shell_list_files_cmd(char argc, char *argv)
  46. {
  47.         if (0 == strcmp("list", &argv[argv[0]]))
  48.     {
  49.                 shell_printf(">List all files in disk1...\r\n");
  50.                 UsrCMD.list_file = true;                  
  51.     }
  52. }


  53. void shell_cat_file_cmd(char argc, char *argv)
  54. {
  55.         if (0 == strcmp("cat", &argv[argv[0]]))
  56.     {       
  57.                 if (argc > 1)
  58.                 {
  59.                         strcpy(UsrCMD.file_name, &argv[argv[1]]);
  60.                         shell_printf(">File : %s\r\n",UsrCMD.file_name);
  61.                         UsrCMD.cat_file = true;
  62.                 }
  63.         }
  64. }

  65. void shell_date_cmd(char argc, char *argv)
  66. {
  67.         if (0 == strcmp("date", &argv[argv[0]]))
  68.     {
  69.                 EasyTime_Get_LocalTime_to_console(MyTime.TimeZone);       
  70.     }
  71. }


 楼主| caizhiwei 发表于 2023-8-9 15:39 | 显示全部楼层
写完了,记得回调函数的注册处理哦~
  1. #ifdef NR_SHELL_USING_EXPORT_CMD
  2. NR_SHELL_CMD_EXPORT(ls, shell_ls_cmd);
  3. NR_SHELL_CMD_EXPORT(test, shell_test_cmd);
  4. #else
  5. const static_cmd_st static_cmd[] =
  6.         {
  7.                 {"ls", shell_ls_cmd},
  8.                 {"update", shell_update_cmd},
  9.         {"reboot", shell_reboot_cmd},
  10.         {"print", shell_print_cmd},
  11.         {"erase", shell_erase_cmd},
  12.                 {"list", shell_list_files_cmd},
  13.                 {"cat", shell_cat_file_cmd},
  14.                 {"date", shell_date_cmd},
  15.                 {"\0", NULL}};
  16. #endif


infobull 发表于 2023-8-21 12:13 来自手机 | 显示全部楼层
支持楼主,顶一个
spark周 发表于 2023-8-22 21:57 | 显示全部楼层
看到这个100进来的
诺曼子 发表于 2023-8-30 21:08 来自手机 | 显示全部楼层
大佬厉害
Pretext 发表于 2023-9-11 10:48 | 显示全部楼层
体验Linux下的微控制器,shell命令行
鹿鼎计 发表于 2023-9-11 12:06 | 显示全部楼层
如果你想查看这篇文章的隐藏内容,请回复
love2008 发表于 2023-9-19 20:48 | 显示全部楼层
感觉还是没有RTT好
Joyje 发表于 2023-10-5 15:43 | 显示全部楼层
感谢分享!!!
digit0 发表于 2023-10-7 11:39 | 显示全部楼层
我一直在寻找shell相关的工具,但没有找到一个合适的
ehua 发表于 2023-10-8 00:07 | 显示全部楼层
如果您要查看本帖隐藏内容请回复
LLGTR 发表于 2023-10-8 15:34 | 显示全部楼层
作为一个轻量级的东西,nr_micro_shell的代码量很少,运行速率较快
芯路例程 发表于 2023-10-11 12:43 | 显示全部楼层
支撑号令补全以及历史记录等功效,便利用户快速输入指令。
V853 发表于 2023-11-2 18:41 | 显示全部楼层
非常适合在嵌入式单片机应用中使用
sun2005 发表于 2023-11-3 08:44 | 显示全部楼层
好东西!谢谢分享!
软核硬核 发表于 2023-11-3 21:03 | 显示全部楼层
支撑一下,试过不少开源shell。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 在线客服 返回列表 返回顶部