u-blox / ublox-cellular-driver-gen

Dependents:   example-ublox-at-cellular-interface-ext example-ublox-cellular-driver-gen HelloMQTT ublox_new_driver_test ... more

Files at this revision

API Documentation at this revision

Comitter:
rob.meades@u-blox.com
Date:
Thu Jun 08 14:40:16 2017 +0100
Parent:
1:458e1b3d460c
Child:
3:027c9eaec52c
Commit message:
Set a minimum time limit for readFile() since otherwise very small files will time out.

Changed in this revision

UbloxCellularDriverGen.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/UbloxCellularDriverGen.cpp	Mon Jun 05 14:11:38 2017 +0000
+++ b/UbloxCellularDriverGen.cpp	Thu Jun 08 14:40:16 2017 +0100
@@ -669,11 +669,15 @@
                     // 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 twice the amount of time it should take to
-                    // read the block at the working baud rate
+                    // 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 * 2 / ((MBED_CONF_UBLOX_CELL_BAUD_RATE / 8) / 1000);
+                    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();
@@ -690,7 +694,8 @@
                         offset += sz_read;
                         _at->recv("OK");
                     } else {
-                        debug_if(_debug_trace_on, "blockSize %d but only received %d bytes\n", blockSize, sz_read);
+                        debug_if(true, "blockSize %d but only received %d bytes within time limit of %d ms\n",
+                        blockSize, sz_read, timeLimit);
                         success = false;
                     }
                } else {