Parser for AT commands and similar protocols

Dependencies:   BufferedSerial

Dependents:   ESP8266 Final_Project_2 Final_Project CHEN_Final_Project

Files at this revision

API Documentation at this revision

Comitter:
Christopher Haster
Date:
Thu Feb 18 16:01:03 2016 -0600
Parent:
12:7d3c3f7ce928
Child:
14:6b8190f55d83
Commit message:
Added better handling of binary data

Changed in this revision

ATParser.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ATParser.cpp	Thu Feb 18 15:59:15 2016 -0600
+++ b/ATParser.cpp	Thu Feb 18 16:01:03 2016 -0600
@@ -229,10 +229,6 @@
         int j = 0;
 
         while (true) {
-            // Ran out of space
-            if (j+1 >= _buffer_size - offset) {
-                return false;
-            }
             // Recieve next character
             int c = getc();
             if (c < 0) {
@@ -260,8 +256,11 @@
                 break;
             }
 
-            // Clear the buffer when we hit a newline
-            if (strcmp(&_buffer[offset + j-_delim_size], _delimiter) == 0) {
+            // Clear the buffer when we hit a newline or ran out of space
+            // running out of space usually means we ran into binary data
+            if (j+1 >= _buffer_size - offset ||
+                strcmp(&_buffer[offset + j-_delim_size], _delimiter) == 0) {
+
                 debug_if(dbg_on, "AT< %s", _buffer+offset);
                 j = 0;
             }