UART Command Parser Time Manager Data Store for SD Card for stm32l476 [it's not Licensed as BSD/GPLx]

Dependencies:   mbed SDFileSystem

Revision:
2:a694440145e9
Parent:
1:71c9c97c9f3d
Child:
7:9ab8809f9693
diff -r 71c9c97c9f3d -r a694440145e9 common/CommandParser.cpp
--- a/common/CommandParser.cpp	Sun Apr 21 02:50:19 2019 +0000
+++ b/common/CommandParser.cpp	Tue Apr 23 08:47:11 2019 +0000
@@ -1,10 +1,12 @@
 #include "global.h"
 
+/* UartLineHandler (start parsing) */
 static void lineHandler(char *line)
 {
     pCP->parse(line);
 }
 
+/* constructor */
 CommandParser::CommandParser(UartReceiver *setUartReceiver, int setDeviceID,
     CmdParseRule *setRuleTable, int setRuleTableLen)
 {
@@ -16,11 +18,13 @@
     pUart = pR->getCurrentUart();
 }
 
+/* start parsing */
 void CommandParser::run(void)
 {
     pR->run();
 }
 
+/* process parsing */
 int CommandParser::parse(char *pStr)
 {
     int rn;
@@ -28,7 +32,7 @@
     char *head;
     /** skip - empty command*/
     if (pStr[0] == '\0') {
-        pUart->printf("[CommandParser::parse] (empty)\n");
+        pUart->printf("(empty)\n");
         return 0;
     }
     /* protection for buffer overrun */
@@ -37,7 +41,7 @@
     
     /* parsing */
     head = pStr;
-    pUart->printf("[CommandParser::parse] %s\n", pStr);
+    pUart->printf("%s\n", pStr);
     
     /** Command Format ":0 CMD 0000" */
     if (len != CmdLen) {
@@ -67,7 +71,8 @@
             continue;
         }
         head += 4;
-        return (*ruleTable[rn].func)(this, head);
+        return (*ruleTable[rn].func)(this, head,
+            ruleTable[rn].exarg);
 
     }
     //pUart->printf("[CommandParser::parse] Invalid Command");
@@ -75,11 +80,13 @@
     return -1;
 }
 
+/* get my Device ID */
 int CommandParser::getDeviceID(void)
 {
     return deviceID;
 }
 
+/* generate ACK/NAK with int code */
 void CommandParser::reply(bool ack, int replyCode)
 {
     char replyStr[] = "0000";
@@ -87,6 +94,7 @@
     this->reply(ack, replyStr);
 }
 
+/* generate ACK/NAK with String */
 void CommandParser::reply(bool ack, char* replyStr)
 {
     const char CmdReplyStrDefault[] = ":0 ACK 0000\n";
@@ -107,4 +115,10 @@
     memcpy(&str[CmdReplyCodePos], replyStr, 4);
     str[CmdReplyEndPos] = '\n';
     pUart->printf(str);
+}
+
+/* get currentUart */
+Serial *CommandParser::getCurrentUart(void)
+{
+    return pUart;
 }
\ No newline at end of file