UART Command Parser Time Manager Data Store for SD Card for stm32l476 [it's not Licensed as BSD/GPLx]
Dependencies: mbed SDFileSystem
Diff: main.cpp
- Revision:
- 1:71c9c97c9f3d
- Parent:
- 0:c347f602596d
- Child:
- 2:a694440145e9
--- a/main.cpp Sat Apr 20 09:23:39 2019 +0000 +++ b/main.cpp Sun Apr 21 02:50:19 2019 +0000 @@ -5,18 +5,16 @@ #include "global.h" #include "string.h" - -class CommandParser; - /** --- Global Variables --- */ Serial pc(SERIAL_TX, SERIAL_RX); DigitalOut myled(LED1); /** --- Prototypes --- */ /** --- Static functions --- */ -static int sampleHanlder(char *arg) +static int sampleHanlder(CommandParser *pC, char *arg) { pc.printf("[sampleHanlder] ARG=%s[EOL]", arg); + pC->reply(); return 0; } @@ -24,6 +22,11 @@ {"CMD", sampleHanlder}, }; +static inline int getNumOfRules(void) +{ + return sizeof(rules)/sizeof(CmdParseRule); +} + /** --- main --- */ int main() { @@ -38,7 +41,7 @@ /* Receive Buffer Control */ pUR = new UartReceiver(&pc); /* Generate Command parser as DeviceID = 0, ParsingRule = rules */ - pCP = new CommandParser(pUR, 0, rules, sizeof(rules)/sizeof(CmdParseRule)); + pCP = new CommandParser(pUR, 0, rules, getNumOfRules()); pCP->run(); pc.printf("Hello World !\n");