From 78c332095a90e68ce36878c2529842d240aeb907 Mon Sep 17 00:00:00 2001 From: FReenen Date: Fri, 5 Apr 2024 19:19:48 +0200 Subject: [PATCH 1/4] add header for CMD module --- CMD/CMD.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 CMD/CMD.h diff --git a/CMD/CMD.h b/CMD/CMD.h new file mode 100644 index 0000000..0613dd7 --- /dev/null +++ b/CMD/CMD.h @@ -0,0 +1,13 @@ +#ifndef CMD_h +#define CMD_h + +typedef CMD_lineOutFn(char* line) CMD_lineoutFn_t; + +// initilize and register the lineout print function +bool init(CMD_lineoutFn_t* lineOut); + +// to recive a single caracter +bool CMD_charIn(char c); + + +#endif \ No newline at end of file From 6c69de372226b748770b4cfd80991238cc74a01a Mon Sep 17 00:00:00 2001 From: FReenen Date: Fri, 5 Apr 2024 19:35:38 +0200 Subject: [PATCH 2/4] first attampt at CMDList_add --- CMDList/CMDList.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/CMDList/CMDList.c b/CMDList/CMDList.c index 7944b78..251323e 100644 --- a/CMDList/CMDList.c +++ b/CMDList/CMDList.c @@ -30,10 +30,30 @@ int CMDList_deinit(CMDList_t *list) int CMDList_add(CMDList_t *list, void* cmd) { char* read_p = cmd; + CMDList_t* list_p = list; - while ((*read_p != 0) && (read_p != ' ') && (read_p - cmd < 500)) + while ( + (read_p != null) + && (*read_p != ' ') // space ends the command + && (*read_p != '\n') // end of line + && (*read_p != '\r') // end of line + && (*read_p != 0) // end of string + && (read_p - cmd < 500) + ) { - + char c = *read_p & (~0x20); // to uppercase + if ((*read_p >= 'A') && (*read_p <= 'Z')) + { + read_p += (read_p - 'A') * sizeof(CMDList_t*); + if (*((CMDList_t**)read_p) == null) + { + read_p = malloc(sizeof(CMDList_t)); + } + else + { + read_p = *((CMDList_t**)read_p) + } + } } } From 3ee76d0925a944ab2baca86776448fdc344f4330 Mon Sep 17 00:00:00 2001 From: FReenen Date: Fri, 5 Apr 2024 20:38:50 +0200 Subject: [PATCH 3/4] rename cmd to cli and add cmd list fifo --- CLI/CLI.h | 16 ++++++++++++++++ CMD/CMD.h | 13 ------------- 2 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 CLI/CLI.h delete mode 100644 CMD/CMD.h diff --git a/CLI/CLI.h b/CLI/CLI.h new file mode 100644 index 0000000..b799b36 --- /dev/null +++ b/CLI/CLI.h @@ -0,0 +1,16 @@ +#ifndef CLI_h +#define CLI_h + +#include "../CMDList.h" +#include "../FIFOFuff.h" + +typedef CLI_lineOutFn(char* line) CLI_lineoutFn_t; + +// initilize and register the lineout print function +bool init(CLI_lineoutFn_t* lineOut, CMDList_t* cmdList, FIFOBuffChar_t* fifo); + +// to recive a single caracter +bool CLI_charIn(char c); + + +#endif \ No newline at end of file diff --git a/CMD/CMD.h b/CMD/CMD.h deleted file mode 100644 index 0613dd7..0000000 --- a/CMD/CMD.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef CMD_h -#define CMD_h - -typedef CMD_lineOutFn(char* line) CMD_lineoutFn_t; - -// initilize and register the lineout print function -bool init(CMD_lineoutFn_t* lineOut); - -// to recive a single caracter -bool CMD_charIn(char c); - - -#endif \ No newline at end of file From 69c6f63251949b949fb9b0e144256ecc27a31ff4 Mon Sep 17 00:00:00 2001 From: FReenen Date: Fri, 5 Apr 2024 20:41:56 +0200 Subject: [PATCH 4/4] remove fifo from cli header and include stdbool.h --- CLI/CLI.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CLI/CLI.h b/CLI/CLI.h index b799b36..a3b65a8 100644 --- a/CLI/CLI.h +++ b/CLI/CLI.h @@ -1,13 +1,14 @@ #ifndef CLI_h #define CLI_h +#include + #include "../CMDList.h" -#include "../FIFOFuff.h" typedef CLI_lineOutFn(char* line) CLI_lineoutFn_t; // initilize and register the lineout print function -bool init(CLI_lineoutFn_t* lineOut, CMDList_t* cmdList, FIFOBuffChar_t* fifo); +bool init(CLI_lineoutFn_t* lineOut, CMDList_t* cmdList); // to recive a single caracter bool CLI_charIn(char c);