From 0af10346603f9deb566a9bf48ec251d9af0c82cb Mon Sep 17 00:00:00 2001 From: hqm <13720409820@163.com> Date: Tue, 28 Sep 2021 10:48:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/arduino/arduino.ino | 4 +- example/arduino/inc | 1 - example/arduino/readme.txt | 1 - example/arduino/src | 1 - example/arduino/test.c | 129 +----------------- example/arduino/test.h | 29 +--- example/arduino/xcmd.c | 1 + example/arduino/xcmd.h | 1 + example/arduino/xcmd_confg.h | 1 + example/arduino/xcmd_default_cmds.c | 1 + example/arduino/xcmd_default_cmds.h | 1 + example/arduino/xcmd_default_keys.c | 1 + example/arduino/xcmd_default_keys.h | 1 + example/arduino/xcmd_define.h | 1 + example/esp_idf/main/CMakeLists.txt | 4 +- example/esp_idf/main/esp_idf.c | 2 - example/linux/Makefile | 4 +- example/linux/linux_main.c | 9 +- .../stm32/MDK/stm32f1xx/Project/test.uvprojx | 4 +- .../stm32/MDK/stm32f4xx/Project/test.uvprojx | 4 +- extensions/test/{src => }/test.c | 3 +- extensions/test/{inc => }/test.h | 2 - inc/xcmd_confg.h | 15 +- src/xcmd.c | 8 +- src/xcmd_default_cmds.c | 6 +- src/xcmd_default_keys.c | 6 +- 26 files changed, 47 insertions(+), 193 deletions(-) delete mode 120000 example/arduino/inc delete mode 100644 example/arduino/readme.txt delete mode 120000 example/arduino/src mode change 100644 => 120000 example/arduino/test.c mode change 100644 => 120000 example/arduino/test.h create mode 120000 example/arduino/xcmd.c create mode 120000 example/arduino/xcmd.h create mode 120000 example/arduino/xcmd_confg.h create mode 120000 example/arduino/xcmd_default_cmds.c create mode 120000 example/arduino/xcmd_default_cmds.h create mode 120000 example/arduino/xcmd_default_keys.c create mode 120000 example/arduino/xcmd_default_keys.h create mode 120000 example/arduino/xcmd_define.h rename extensions/test/{src => }/test.c (99%) rename extensions/test/{inc => }/test.h (95%) diff --git a/example/arduino/arduino.ino b/example/arduino/arduino.ino index dcd5f49..84415ff 100755 --- a/example/arduino/arduino.ino +++ b/example/arduino/arduino.ino @@ -7,9 +7,7 @@ * @FilePath: /xcmd/example/arduino/arduino.ino */ #include -#include "inc/xcmd.h" -#include "inc/xcmd_default_keys.h" -#include "inc/xcmd_default_cmds.h" +#include "xcmd.h" #include "test.h" int cmd_get_char(uint8_t *ch) diff --git a/example/arduino/inc b/example/arduino/inc deleted file mode 120000 index 6a14105..0000000 --- a/example/arduino/inc +++ /dev/null @@ -1 +0,0 @@ -../../inc/ \ No newline at end of file diff --git a/example/arduino/readme.txt b/example/arduino/readme.txt deleted file mode 100644 index 2900118..0000000 --- a/example/arduino/readme.txt +++ /dev/null @@ -1 +0,0 @@ -需要把根目录的inc和src拷贝到当前目录才能编译通过 \ No newline at end of file diff --git a/example/arduino/src b/example/arduino/src deleted file mode 120000 index a8d2a67..0000000 --- a/example/arduino/src +++ /dev/null @@ -1 +0,0 @@ -../../src/ \ No newline at end of file diff --git a/example/arduino/test.c b/example/arduino/test.c deleted file mode 100644 index aeab4d5..0000000 --- a/example/arduino/test.c +++ /dev/null @@ -1,128 +0,0 @@ -/* - * @Author: your name - * @Date: 2021-09-22 22:33:17 - * @LastEditTime: 2021-09-22 23:17:02 - * @LastEditors: Please set LastEditors - * @Description: In User Settings Edit - * @FilePath: /xcmd/extensions/test/test.c - */ -#include "test.h" -#include -#include - -#define EXIT_MESSAGE() xcmd_print(g_cmder, "press \"q\" or \"Q\" to exit!\r\n") - -#define EXIT_CHECK() \ - do \ - (toupper(GET_CHAR()) == 'Q') \ - { \ - uint8_t c; \ - if (GET_CHAR(&c)) \ - { \ - switch (c) \ - case 'q': \ - case 'Q': \ - case 0x1B: \ - return; \ - } \ - } \ - while (0); - -static uint8_t param_check(int need, int argc, char*argv[]) -{ - uint8_t i,ret = 0; - if(need<(argc)) - { - ret = 1; - } - else - { - xcmd_print("err need %d but input %d:\r\n", need, argc-1); - xcmd_print("input= "); - for(i=0; i #include #include "xcmd.h" -#include "xcmd_default_keys.h" -#include "xcmd_default_cmds.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "test.h" diff --git a/example/linux/Makefile b/example/linux/Makefile index ed8c484..acb8f6a 100755 --- a/example/linux/Makefile +++ b/example/linux/Makefile @@ -1,10 +1,10 @@ OBJ += xcmd.o xcmd_default_keys.o xcmd_default_cmds.o linux_main.o test.o BIN = xcmder VPATH := ../../src \ - ../../extensions/test/src + ../../extensions/test INC += -I../../inc \ - -I../../extensions/test/inc + -I../../extensions/test OBJ_WITH_BUILD_DIR:=$(addprefix build/,$(OBJ)) diff --git a/example/linux/linux_main.c b/example/linux/linux_main.c index e5d4d68..eb83409 100755 --- a/example/linux/linux_main.c +++ b/example/linux/linux_main.c @@ -9,13 +9,10 @@ #include #include #include -#include "xcmd.h" -#include "xcmd_default_keys.h" -#include "xcmd_default_cmds.h" -#include -#include -#include +#include +#include #include +#include "xcmd.h" #include "test.h" int getch(void) diff --git a/example/stm32/MDK/stm32f1xx/Project/test.uvprojx b/example/stm32/MDK/stm32f1xx/Project/test.uvprojx index e7b39ee..cd1908f 100644 --- a/example/stm32/MDK/stm32f1xx/Project/test.uvprojx +++ b/example/stm32/MDK/stm32f1xx/Project/test.uvprojx @@ -338,7 +338,7 @@ USE_STDPERIPH_DRIVER,STM32F10X_MD - ..\Libraries\CMSIS\Device\ST\STM32F10x\Include;..\Libraries\STM32F10x_StdPeriph_Driver\inc;..\Libraries\CMSIS\Include;..\User;..\User\port;..\..\..\..\..\inc;..\lib\inc;..\..\..\..\..\extensions\test\inc + ..\Libraries\CMSIS\Device\ST\STM32F10x\Include;..\Libraries\STM32F10x_StdPeriph_Driver\inc;..\Libraries\CMSIS\Include;..\User;..\User\port;..\..\..\..\..\inc;..\lib\inc;..\..\..\..\..\extensions\test @@ -581,7 +581,7 @@ test.c 1 - ..\..\..\..\..\extensions\test\src\test.c + ..\..\..\..\..\extensions\test\test.c diff --git a/example/stm32/MDK/stm32f4xx/Project/test.uvprojx b/example/stm32/MDK/stm32f4xx/Project/test.uvprojx index fb372d6..a78d340 100644 --- a/example/stm32/MDK/stm32f4xx/Project/test.uvprojx +++ b/example/stm32/MDK/stm32f4xx/Project/test.uvprojx @@ -338,7 +338,7 @@ STM32F427_437xx,USE_STDPERIPH_DRIVER - ..\FWLIB\CORE;..\FWLIB\inc;..\System\debug;..\System\delay;..\System\sys;..\System\debug;..\user;..\user\bsp\inc;..\user\bsp;..\..\..\..\..\inc;..\..\..\..\..\extensions\test\inc + ..\FWLIB\CORE;..\FWLIB\inc;..\System\debug;..\System\delay;..\System\sys;..\System\debug;..\user;..\user\bsp\inc;..\user\bsp;..\..\..\..\..\inc;..\..\..\..\..\extensions\test @@ -670,7 +670,7 @@ test.c 1 - ..\..\..\..\..\extensions\test\src\test.c + ..\..\..\..\..\extensions\test\test.c diff --git a/extensions/test/src/test.c b/extensions/test/test.c similarity index 99% rename from extensions/test/src/test.c rename to extensions/test/test.c index 86cad59..ff37e49 100644 --- a/extensions/test/src/test.c +++ b/extensions/test/test.c @@ -6,9 +6,10 @@ * @Description: In User Settings Edit * @FilePath: /xcmd/extensions/test/test.c */ -#include "test.h" #include #include +#include "xcmd.h" +#include "test.h" #define EXIT_MESSAGE() xcmd_print(g_cmder, "press \"q\" or \"Q\" to exit!\r\n") diff --git a/extensions/test/inc/test.h b/extensions/test/test.h similarity index 95% rename from extensions/test/inc/test.h rename to extensions/test/test.h index 1f97066..eed2eb2 100644 --- a/extensions/test/inc/test.h +++ b/extensions/test/test.h @@ -10,8 +10,6 @@ #ifndef TEST_H #define TEST_H -#include "xcmd.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/inc/xcmd_confg.h b/inc/xcmd_confg.h index 29b02b5..fb83e61 100755 --- a/inc/xcmd_confg.h +++ b/inc/xcmd_confg.h @@ -15,10 +15,21 @@ extern "C" { #define VERSION "1.0.0" -#define XCMD_LINE_MAX_LENGTH (256) /* 命令行支持的最大字符数 */ +#ifndef XCMD_LINE_MAX_LENGTH +#define XCMD_LINE_MAX_LENGTH (64) /* 命令行支持的最大字符数 */ +#endif + +#ifndef XCMD_PRINT_BUF_MAX_LENGTH #define XCMD_PRINT_BUF_MAX_LENGTH (128) /* xcmd_print缓存 */ +#endif + +#ifndef XCMD_HISTORY_MAX_NUM #define XCMD_HISTORY_MAX_NUM (8) /* 支持的历史记录个数,0为不支持 */ -#define XCMD_PARAM_MAX_NUM (16) /* 支持输入的参数个数 */ +#endif + +#ifndef XCMD_PARAM_MAX_NUM +#define XCMD_PARAM_MAX_NUM (8) /* 支持输入的参数个数 */ +#endif #if XCMD_PRINT_BUF_MAX_LENGTH < (XCMD_LINE_MAX_LENGTH+32) #undef XCMD_PRINT_BUF_MAX_LENGTH diff --git a/src/xcmd.c b/src/xcmd.c index ca28abb..63a19c1 100755 --- a/src/xcmd.c +++ b/src/xcmd.c @@ -1,7 +1,7 @@ -#include "../inc/xcmd.h" -#include "../inc/xcmd_confg.h" -#include "../inc/xcmd_default_cmds.h" -#include "../inc/xcmd_default_keys.h" +#include "xcmd_confg.h" +#include "xcmd.h" +#include "xcmd_default_cmds.h" +#include "xcmd_default_keys.h" #include #include diff --git a/src/xcmd_default_cmds.c b/src/xcmd_default_cmds.c index 3473174..beab2b6 100755 --- a/src/xcmd_default_cmds.c +++ b/src/xcmd_default_cmds.c @@ -6,9 +6,9 @@ * @Description: In User Settings Edit * @FilePath: /xcmd/src/xcmd_default_cmds.c */ -#include "../inc/xcmd_default_cmds.h" -#include "../inc/xcmd.h" -#include "../inc/xcmd_confg.h" +#include "xcmd_confg.h" +#include "xcmd_default_cmds.h" +#include "xcmd.h" #include static void cmd_clear(int argc, char* argv[]) diff --git a/src/xcmd_default_keys.c b/src/xcmd_default_keys.c index d3ed491..1ac4fa4 100755 --- a/src/xcmd_default_keys.c +++ b/src/xcmd_default_keys.c @@ -6,9 +6,9 @@ * @Description: In User Settings Edit * @FilePath: /xcmd/src/xcmd_default_keys.c */ -#include "../inc/xcmd_default_keys.h" -#include "../inc/xcmd_confg.h" -#include "../inc/xcmd.h" +#include "xcmd_confg.h" +#include "xcmd.h" +#include "xcmd_default_keys.h" static int xcmd_del_char(void *pv) {