ublox-cellular-driver-gen Fork

Fork of ublox-cellular-driver-gen by u-blox

Files at this revision

API Documentation at this revision

Comitter:
rob.meades@u-blox.com
Date:
Fri Jun 16 00:49:52 2017 +0100
Parent:
6:804d544f8d8c
Commit message:
C027 compatibility: don't check the response filename when doing a block read as teh Sara-G350 module doesn't always return it. Increase the minimum wait time for a read response and the maximum wait time as well, again 'cos Sara-G350 is not as responsive as Sara-U201.

Changed in this revision

TESTS/unit_tests/file-system/main.cpp Show annotated file Show diff for this revision Revisions of this file
UbloxCellularDriverGen.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/TESTS/unit_tests/file-system/main.cpp	Thu Jun 15 07:19:40 2017 +0100
+++ b/TESTS/unit_tests/file-system/main.cpp	Fri Jun 16 00:49:52 2017 +0100
@@ -46,7 +46,7 @@
 #ifndef MBED_CONF_APP_FILE_SIZE
 # ifdef TARGET_UBLOX_C027
 // C027 doesn't have so much RAM.
-// TODO: it should be possible to use, say 1200
+// TODO: it should be possible to use, say 12000
 // here but it seems that the Sara-G350 module
 // needs flow control so that it can slow
 // things down while flash writees complete
--- a/UbloxCellularDriverGen.cpp	Thu Jun 15 07:19:40 2017 +0100
+++ b/UbloxCellularDriverGen.cpp	Fri Jun 16 00:49:52 2017 +0100
@@ -641,7 +641,6 @@
     int blockSize = FILE_BUFFER_SIZE;
     char respFilename[48 + 1];
     int sz, sz_read;
-    char * endQuote;
     bool success = true;
     int ch = 0;
     int timeLimit;
@@ -665,46 +664,38 @@
 
             if (blockSize > 0) {
                 if (_at->send("AT+URDBLOCK=\"%s\",%d,%d\r\n", filename, offset, blockSize) &&
-                    _at->recv("+URDBLOCK: %48[^,],%d,\"", respFilename, &sz)) {
-                    // On some modules the response filename is not in quotes,
-                    // on others it is, so strip them here
-                    if ((*respFilename == '"') && ((endQuote = strchr(respFilename + 1, '"')) != NULL)) {
-                        memcpy (respFilename, respFilename + 1, endQuote - respFilename - 1);
-                        *(endQuote - 1) = 0;
+                    _at->recv("+URDBLOCK:%48[^,],%d,\"", respFilename, &sz)) {
+                    // Note: not checking respFilename as some modules (e.g. Sara-G350 00S-00)
+                    // doesn't always include it.
+                    // Would use _at->read() here, but if it runs ahead of the
+                    // serial stream it returns -1 instead of the number of characters
+                    // read so far, which is not very helpful so instead use _at->getc() and
+                    // a time limit. The time limit is four times the amount of time it
+                    // should take to read the block at the working baud rate with a minimum
+                    // of 100 ms (for short files)
+                    timer.reset();
+                    timer.start();
+                    timeLimit = blockSize * 4 / ((MBED_CONF_UBLOX_CELL_BAUD_RATE / 8) / 1000);
+                    if (timeLimit < 100) {
+                        timeLimit = 100;
                     }
-                    if (strcmp(filename, respFilename) == 0) {
-                        // Would use _at->read() here, but if it runs ahead of the
-                        // serial stream it returns -1 instead of the number of characters
-                        // read so far, which is not very helpful so instead use _at->getc() and
-                        // a time limit. The time limit is three times the amount of time it
-                        // should take to read the block at the working baud rate with a minimum
-                        // of 10 ms (for short files)
-                        timer.reset();
-                        timer.start();
-                        timeLimit = blockSize * 3 / ((MBED_CONF_UBLOX_CELL_BAUD_RATE / 8) / 1000);
-                        if (timeLimit < 10) {
-                            timeLimit = 10;
+                    sz_read = 0;
+                    while ((sz_read < blockSize) && (timer.read_ms() < timeLimit)) {
+                        ch = _at->getc();
+                        if (ch >= 0) {
+                            *buf = ch;
+                            buf++;
+                            sz_read++;
                         }
-                        sz_read = 0;
-                        while ((sz_read < blockSize) && (timer.read_ms() < timeLimit)) {
-                            ch = _at->getc();
-                            if (ch >= 0) {
-                                *buf = ch;
-                                buf++;
-                                sz_read++;
-                            }
-                        }
-                        timer.stop();
+                    }
+                    timer.stop();
 
-                        if (sz_read == blockSize) {
-                            bytesToRead -= sz_read;
-                            offset += sz_read;
-                            _at->recv("OK");
-                        } else {
-                        debug_if(_debug_trace_on, "blockSize %d but only received %d bytes\n", blockSize, sz_read);
-                            success = false;
-                        }
+                    if (sz_read == blockSize) {
+                        bytesToRead -= sz_read;
+                        offset += sz_read;
+                        _at->recv("OK");
                     } else {
+                    debug_if(_debug_trace_on, "blockSize %d but only received %d bytes\n", blockSize, sz_read);
                         success = false;
                     }
                } else {