Parser for AT commands and similar protocols

Dependencies:   BufferedSerial

Dependents:   ESP8266 xdot-passthru Lab_10 Lab9 ... more

Fork of ATParser by NetworkSocketAPI

Revision:
2:4d68f546861c
Parent:
1:66a14afe650a
Child:
3:32915b9467d2
--- a/ATParser.cpp	Thu Jul 16 20:42:44 2015 +0000
+++ b/ATParser.cpp	Thu Jul 16 22:50:43 2015 +0000
@@ -22,7 +22,7 @@
 #include <cstdarg>
 
 // This can be defined to assist in debugging
-//#define AT_ECHO 1
+#define AT_ECHO 1
 
 
 // getc/putc handling with timeouts
@@ -168,11 +168,11 @@
                 return false;
             }
             
-            int count;
+            int count = -1;
             sscanf(_buffer+offset, _buffer, &count);
             
             // We only succeed if all characters in the response is matched
-            if ((_buffer+offset)[count] == 0) {
+            if (count >= 0 && (_buffer+offset)[count] == 0) {
                 // Reuse the front end of the buffer
                 int j;
                 for (j = 0; j < i; j++) {