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

Dependencies:   mbed SDFileSystem

Revision:
19:36072b9b79f3
Parent:
17:c2709a9c0a68
--- a/event.cpp	Fri Jun 14 00:21:09 2019 +0000
+++ b/event.cpp	Fri Jul 05 01:26:19 2019 +0000
@@ -66,7 +66,7 @@
     bool success;
     success = pDevRept->start();
     if (!success) {
-        pC->reply(false, 3);
+        pC->reply(false, CommandParser::NakCode::NAK_IN_RUNNING);
         return 1;
     }
     pC->reply();
@@ -78,7 +78,7 @@
     bool success;
     success = pDevRept->stop();
     if (!success) {
-        pC->reply(false, 3);
+        pC->reply(false, CommandParser::NakCode::NAK_IN_STOPPED);
         return 1;
     }
     pC->reply();
@@ -90,7 +90,7 @@
     bool success;
     success = pDevRept->readyToStart();
     if (!success) {
-        pC->reply(false, 3);
+        pC->reply(false, CommandParser::NakCode::NAK_IN_RUNNING);
         return 1;
     }
     pC->reply();
@@ -103,7 +103,7 @@
     int setvalue = atoi(arg);
     success = pDevRept->setRepeatCount(setvalue);
     if (!success) {
-        pC->reply(false, 4);
+        pC->reply(false, CommandParser::NakCode::NAK_IN_RUNNING);
         return 1;
     }
     pC->reply();
@@ -126,12 +126,12 @@
         /* NOP setvalue = setvalue */
     } else {
         /* invalid format */
-        pC->reply(false, 6);
+        pC->reply(false, CommandParser::NakCode::NAK_INVAL_PARAM);
         return 1;
     }
     success = pDevRept->setRepeatStride(setvalue);
     if (!success) {
-        pC->reply(false, 5);
+        pC->reply(false, CommandParser::NakCode::NAK_IN_RUNNING);
         return 1;
     }
     pC->reply();
@@ -148,13 +148,13 @@
         setMode = false;
     } else {
         /* INVALID COMMAND */
-        pC->reply(false, 7);
+        pC->reply(false, CommandParser::NakCode::NAK_INVAL_PARAM);
         return 1;        
     }
     success = pDevRept->setRepeatSingleShot(setMode);
     if (success != true) {
         /* INVALID COMMAND in SetMode */
-        pC->reply(false, 5);
+        pC->reply(false, CommandParser::NakCode::NAK_IN_RUNNING);
         return 1;        
     }
     pC->reply();
@@ -170,7 +170,7 @@
     int setvalue = strtol(arg, NULL, 16);
     success = pDevRept->setConfigId(setvalue);
     if (!success) {
-        pC->reply(false, 3);
+        pC->reply(false,  CommandParser::NakCode::NAK_INVAL_SEQ);
         return 1;
     }
     pC->reply();
@@ -183,7 +183,7 @@
     int setvalue = strtol(arg, NULL, 16);
     success = pDevRept->setConfigValue(setvalue);
     if (!success) {
-        pC->reply(false, 3);
+        pC->reply(false, CommandParser::NakCode::NAK_INVAL_SEQ);
         return 1;
     }
     pC->reply();
@@ -198,7 +198,7 @@
     
     success = pDevRept->getConfigValue(&getvalue);
     if (!success) {
-        pC->reply(false, 3);
+        pC->reply(false, CommandParser::NakCode::NAK_INVAL_SEQ);
         return 1;
     }
     uprintf(":%d CFG 0004 %04x\n", pC->getDeviceID(), getvalue);
@@ -223,8 +223,11 @@
 /* Sample Command */
 static int sampleHanlder(CommandParser *pC, char *arg, int exarg)
 {   
-    pC->reply();
-    return 0;
+    wait(1);
+    NVIC_SystemReset();
+    /* Never Reached. */
+    pC->reply(false, CommandParser::NakCode::NAK_INVAL_SEQ);
+    return 1;
 }
 
 /****************************************************/
@@ -233,7 +236,7 @@
 static int startSDStore(CommandParser *pC, char *arg, int exarg)
 {
     if (pSds->startFileWithTimeStamp("","txt") != true) {
-        pC->reply(false, 1);
+        pC->reply(false, CommandParser::NakCode::NAK_INTERNAL_ERR);
         return 1;
     }
     pC->reply();
@@ -262,7 +265,7 @@
     
     if ((fp = pSds->getFilePointer()) == NULL) {
         /* NOP */
-        pC->reply(false, 2);
+        pC->reply(false, CommandParser::NakCode::NAK_INVAL_SEQ);
         return 2;
     }
     pTM->getTimeStamp(curr);
@@ -291,7 +294,7 @@
         success = pTM->setCurrentTime(exarg,setvalue);
         break;
     }
-    pC->reply(success, (success)? 0 : setvalue );
+    pC->reply(success, (success)? 0 : CommandParser::NakCode::NAK_INVAL_PARAM );
     return 0;
 }