editable serial input line buffer

Dependents:   MAX5715BOB_Tester MAX11131BOB_Tester MAX5171BOB_Tester MAX11410BOB_Tester ... more

Revision:
7:0bda7cfee767
Parent:
6:88e92f832c9a
Child:
9:12e37800ecdd
--- a/CmdLine.cpp	Tue Aug 13 16:20:23 2019 -0700
+++ b/CmdLine.cpp	Fri Sep 27 11:10:09 2019 +0000
@@ -691,6 +691,28 @@
     return false; // no match
 }
 
+/** CmdLine::parse_double matches "key"=value
+ *
+ * @return true if keyword was found in buffer
+ * @param[in] key string value to match
+ * @param[out] doubleVar updated from value string if match "key"=value
+ *
+ * @post on successful match, the key=value substring is deleted from cmdbuf
+ *
+ */
+bool CmdLine::parse_double(const char *key, double& doubleVar)
+{
+    char valueBuf[16];
+    char *end;
+    // bool parse_and_remove_key(const char *key, char *valueBuf, int valueBufLen);
+    if (parse_and_remove_key(key, valueBuf, sizeof(valueBuf)))
+    {
+        doubleVar = strtof(valueBuf, &end);
+        return true;
+    }
+    return false; // no match
+}
+
 /** CmdLine::parse_float matches "key"=value
  *
  * @return true if keyword was found in buffer