Remove spurious debug parameter.

Fork of ublox-at-cellular-interface by u-blox

Files at this revision

API Documentation at this revision

Comitter:
RobMeades
Date:
Mon Oct 30 14:48:14 2017 +0000
Parent:
9:ffab574dcc20
Child:
11:cc41a8636f7e
Child:
12:ff6fac481487
Commit message:
Merge pull request from amq: usord and usorf can potentially return more data than originally requested, handle this situation if it occurs.

Changed in this revision

UbloxATCellularInterface.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/UbloxATCellularInterface.cpp	Wed Sep 27 15:33:07 2017 +0500
+++ b/UbloxATCellularInterface.cpp	Mon Oct 30 14:48:14 2017 +0000
@@ -688,8 +688,12 @@
                                   // losing characters in UARTSerial
             if (_at->send("AT+USORD=%d,%d", socket->modem_handle, read_blk) &&
                 _at->recv("+USORD: %*d,%d,\"", &usord_sz)) {
-                socket->pending -= usord_sz; // Must use what +USORD returns here as it
-                                             // may be less than we asked for
+                // Must use what +USORD returns here as it may be less or more than we asked for
+                if (usord_sz > socket->pending) {
+                    socket->pending = 0;
+                } else {
+                    socket->pending -= usord_sz; 
+                }
                 // Note: insert no debug between _at->recv() and _at->read(), no time...
                 if (usord_sz > size) {
                     usord_sz = size;
@@ -803,8 +807,12 @@
             if (_at->send("AT+USORF=%d,%d", socket->modem_handle, read_blk) &&
                 _at->recv("+USORF: %*d,\"%" u_stringify(NSAPI_IP_SIZE) "[^\"]\",%d,%d,\"",
                           ipAddress, &port, &usorf_sz)) {
-                socket->pending -= usorf_sz; // Must use what +USORF returns here as it
-                                             // may be less than we asked for
+                // Must use what +USORF returns here as it may be less or more than we asked for
+                if (usorf_sz > socket->pending) {
+                    socket->pending = 0;
+                } else {
+                    socket->pending -= usorf_sz; 
+                }
                 // Note: insert no debug between _at->recv() and _at->read(), no time...
                 if (usorf_sz > size) {
                     usorf_sz = size;