s

Dependencies:   BufferedSerial

Files at this revision

API Documentation at this revision

Comitter:
mridup
Date:
Mon Jul 04 12:08:15 2016 +0000
Parent:
14:6b8190f55d83
Child:
16:b9b53df4dc4d
Commit message:
recv AT response with last chars as numbers and ending with CR-LF.(no non-digit last char)

Changed in this revision

ATParser.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ATParser.cpp	Fri Apr 01 17:27:30 2016 +0000
+++ b/ATParser.cpp	Mon Jul 04 12:08:15 2016 +0000
@@ -227,7 +227,7 @@
         // We keep trying the match until we succeed or some other error
         // derails us.
         int j = 0;
-
+        
         while (true) {
             // Recieve next character
             int c = getc();
@@ -240,9 +240,30 @@
             // Check for match
             int count = -1;
             sscanf(_buffer+offset, _buffer, &count);
-
+            
             // We only succeed if all characters in the response are matched
-            if (count == j) {
+            if(count==j) {
+                    //check if last input is a number
+                    if (_buffer[offset-6]=='%' && _buffer[offset-5]=='*' 
+                        && (_buffer[offset-4]=='x' || _buffer[offset-4]=='d' || _buffer[offset-4]=='u'))
+                    {
+                        //if the last char is a number, keep getting the next character till CR
+                        while(1)
+                        {
+                            int c = getc();
+                            if (c < 0) {
+                                return false;
+                            }
+                            if(c==0xD) {//there is no next number so exit from condition                                
+                                break;
+                            }
+                            else {
+                                _buffer[offset + j++] = c;
+                                _buffer[offset + j] = 0;
+                            }
+                        }
+                    }
+                    
                 debug_if(dbg_on, "AT= %s\r\n", _buffer+offset);
                 // Reuse the front end of the buffer
                 memcpy(_buffer, response, i);