From 9c52398855c57c03bc72ecd565b8fb412294a4d3 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 09:53:26 +0000 Subject: [PATCH 01/13] Correct DBD_RINGBUFFER_LEN. Correct SAT_NAV MAX_BLOCKS checking. Remove negative size_t checks. Add extra diagnostic for readNavigationDatabase. --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 44 ++++++++++++-------- src/u-blox_structs.h | 9 +++- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index a8e1e1f..391355e 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -2413,10 +2413,11 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg) packetUBXNAVSAT->data.header.version = extractByte(msg, 4); packetUBXNAVSAT->data.header.numSvs = extractByte(msg, 5); - for (uint8_t i = 0; (i < UBX_NAV_SAT_MAX_BLOCKS) && (i < packetUBXNAVSAT->data.header.numSvs) - && ((((uint16_t)i) * 12) < (msg->len - 8)); i++) + // The NAV SAT message could contain data for 255 SVs max. (numSvs is uint8_t. UBX_NAV_SAT_MAX_BLOCKS is 255) + for (uint16_t i = 0; (i < UBX_NAV_SAT_MAX_BLOCKS) && (i < ((uint16_t)packetUBXNAVSAT->data.header.numSvs)) + && ((i * 12) < (msg->len - 8)); i++) { - uint16_t offset = (((uint16_t)i) * 12) + 8; + uint16_t offset = (i * 12) + 8; packetUBXNAVSAT->data.blocks[i].gnssId = extractByte(msg, offset + 0); packetUBXNAVSAT->data.blocks[i].svId = extractByte(msg, offset + 1); packetUBXNAVSAT->data.blocks[i].cno = extractByte(msg, offset + 2); @@ -4217,7 +4218,7 @@ size_t SFE_UBLOX_GNSS::pushAssistNowDataInternal(size_t offset, bool skipTime, c { size_t dataPtr = offset; // Pointer into dataBytes - if ((offset >= numDataBytes) || (offset < 0)) // Sanity check. Return now if offset is invalid. + if (offset >= numDataBytes) // Sanity check. Return now if offset is invalid. { #ifndef SFE_UBLOX_REDUCED_PROG_MEM if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging @@ -4230,17 +4231,6 @@ size_t SFE_UBLOX_GNSS::pushAssistNowDataInternal(size_t offset, bool skipTime, c return ((size_t)0); } - if (numDataBytes < 0) // Sanity check. Return now if numDataBytes is negative. - { -#ifndef SFE_UBLOX_REDUCED_PROG_MEM - if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging - { - _debugSerial->println(F("pushAssistNowData: numDataBytes is negative! Aborting...")); - } -#endif - return ((size_t)0); - } - size_t packetsProcessed = 0; // Keep count of how many packets have been processed size_t bytesPushed = 0; // Keep count @@ -4894,14 +4884,15 @@ size_t SFE_UBLOX_GNSS::readNavigationDatabase(uint8_t *dataBytes, size_t maxNumD while (packetUBXMGAACK->head != packetUBXMGAACK->tail) // Does the MGA ACK ringbuffer contain any data? { // Check if we've received the correct ACK + bool idMatch = (packetUBXMGAACK->data[packetUBXMGAACK->tail].msgId == UBX_MGA_DBD); // Check if the message ID matches + bool dataAckd = true; - dataAckd &= (packetUBXMGAACK->data[packetUBXMGAACK->tail].msgId == UBX_MGA_DBD); // Check if the message ID matches dataAckd &= (packetUBXMGAACK->data[packetUBXMGAACK->tail].msgPayloadStart[0] == (uint8_t)(databaseEntriesRX & 0xFF)); // Check if the ACK contents match databaseEntriesRX dataAckd &= (packetUBXMGAACK->data[packetUBXMGAACK->tail].msgPayloadStart[1] == (uint8_t)((databaseEntriesRX >> 8) & 0xFF)); dataAckd &= (packetUBXMGAACK->data[packetUBXMGAACK->tail].msgPayloadStart[2] == (uint8_t)((databaseEntriesRX >> 16) & 0xFF)); dataAckd &= (packetUBXMGAACK->data[packetUBXMGAACK->tail].msgPayloadStart[3] == (uint8_t)((databaseEntriesRX >> 24) & 0xFF)); - if (dataAckd) // Is the ACK valid? + if (idMatch && dataAckd) // Is the ACK valid? { #ifndef SFE_UBLOX_REDUCED_PROG_MEM if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging @@ -4917,6 +4908,25 @@ size_t SFE_UBLOX_GNSS::readNavigationDatabase(uint8_t *dataBytes, size_t maxNumD #endif keepGoing = false; } + else if (idMatch) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->print(F("readNavigationDatabase: unexpected ACK received. databaseEntriesRX is 0x")); + _debugSerial->print(databaseEntriesRX, HEX); + _debugSerial->print(F(". msgPayloadStart is 0x")); + for (uint8_t i = 4; i > 0; i--) + { + if (packetUBXMGAACK->data[packetUBXMGAACK->tail].msgPayloadStart[i - 1] < 0x10) + _debugSerial->print(F("0")); + _debugSerial->print(packetUBXMGAACK->data[packetUBXMGAACK->tail].msgPayloadStart[i - 1], HEX); + } + _debugSerial->println(); + } +#endif + } + // Increment the tail packetUBXMGAACK->tail++; if (packetUBXMGAACK->tail == UBX_MGA_ACK_DATA0_RINGBUFFER_LEN) diff --git a/src/u-blox_structs.h b/src/u-blox_structs.h index be78cfe..4a6791d 100644 --- a/src/u-blox_structs.h +++ b/src/u-blox_structs.h @@ -917,7 +917,7 @@ typedef struct } UBX_NAV_TIMELS_t; // UBX-NAV-SAT (0x01 0x35): Satellite Information -const uint16_t UBX_NAV_SAT_MAX_BLOCKS = 256; // TO DO: confirm if this is large enough for all modules +const uint16_t UBX_NAV_SAT_MAX_BLOCKS = 255; // numSvs is 8-bit const uint16_t UBX_NAV_SAT_MAX_LEN = 8 + (12 * UBX_NAV_SAT_MAX_BLOCKS); typedef struct @@ -1817,7 +1817,12 @@ typedef struct uint8_t dbdEntryChecksumB; } UBX_MGA_DBD_data_t; -#define UBX_MGA_DBD_RINGBUFFER_LEN 256 // Provide storage for MGA DBD packets. TO DO: confirm if 256 is large enough! +#if defined(ARDUINO_AVR_UNO) +#define UBX_MGA_DBD_RINGBUFFER_LEN 3 // Fix to let the code compile on the UNO. (The UNO does not have enough RAM to store the database.) +#else +#define UBX_MGA_DBD_RINGBUFFER_LEN 250 // Provide storage for MGA DBD packets. TO DO: confirm if 250 is large enough for all modules! +#endif + typedef struct { uint8_t head; From 1b7ba984c3352196a1649175c4ca9944e58cae25 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 10:15:08 +0000 Subject: [PATCH 02/13] Add tree/GITHUB_REF to yml file so Compile Sketch runs on the current branch, not main --- .github/workflows/compile-sketch.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index 97efba1..6dc5f7a 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -1,7 +1,7 @@ name: Compile Sketch on: - # - push + - push - pull_request @@ -88,13 +88,16 @@ jobs: - name: Checkout uses: actions/checkout@v2 + - name: Branch name + run: echo running on branch ${GITHUB_REF##*/} + - name: Compile Sketch uses: arduino/compile-sketches@v1 with: platforms: ${{ matrix.board.platforms }} fqbn: ${{ matrix.board.fqbn }} libraries: | - - source-url: https://github.com/${{github.repository}}.git + - source-url: https://github.com/${{github.repository}}/tree/${GITHUB_REF##*/}.git sketch-paths: | - examples/Example10_AltitudeMSL - examples/Example11_ResetModule/Example1_FactoryDefaultviaI2C From 93d947352f49f97a59188ef9c6944adcb1e1f1a9 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 10:37:38 +0000 Subject: [PATCH 03/13] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index 6dc5f7a..dc606ab 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -97,7 +97,7 @@ jobs: platforms: ${{ matrix.board.platforms }} fqbn: ${{ matrix.board.fqbn }} libraries: | - - source-url: https://github.com/${{github.repository}}/tree/${GITHUB_REF##*/}.git + - source-url: https://github.com/${{github.repository}}/tree/${{GITHUB_REF##*/}}.git sketch-paths: | - examples/Example10_AltitudeMSL - examples/Example11_ResetModule/Example1_FactoryDefaultviaI2C From b82a1293bbadfad274c4a963aca77cd4cb9dfa9d Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 11:37:44 +0000 Subject: [PATCH 04/13] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index dc606ab..445febf 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -87,7 +87,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - + - name: Branch name run: echo running on branch ${GITHUB_REF##*/} @@ -97,7 +97,7 @@ jobs: platforms: ${{ matrix.board.platforms }} fqbn: ${{ matrix.board.fqbn }} libraries: | - - source-url: https://github.com/${{github.repository}}/tree/${{GITHUB_REF##*/}}.git + - source-url: https://github.com/tree/AssistNow.git sketch-paths: | - examples/Example10_AltitudeMSL - examples/Example11_ResetModule/Example1_FactoryDefaultviaI2C @@ -106,7 +106,6 @@ jobs: - examples/Example14_DebugOutput - examples/Example15_GetDateTime - examples/Example16_Nanosecond_MaxOutput - - examples/Example16_PartialSecond_MaxOutput - examples/Example18_PowerSaveMode - examples/Example19_DynamicModel - examples/Example20_SendCustomCommand From e59588acc55519c7683acd587604220ded5dd978 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 11:39:59 +0000 Subject: [PATCH 05/13] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index 445febf..c8cf6bc 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -97,7 +97,7 @@ jobs: platforms: ${{ matrix.board.platforms }} fqbn: ${{ matrix.board.fqbn }} libraries: | - - source-url: https://github.com/tree/AssistNow.git + - source-url: https://github.com/${{github.repository}}/tree/AssistNow.git sketch-paths: | - examples/Example10_AltitudeMSL - examples/Example11_ResetModule/Example1_FactoryDefaultviaI2C From c30d0b88d25884e4919b63bc93a40417032164b7 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 11:44:07 +0000 Subject: [PATCH 06/13] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index c8cf6bc..d0dbb79 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -97,7 +97,8 @@ jobs: platforms: ${{ matrix.board.platforms }} fqbn: ${{ matrix.board.fqbn }} libraries: | - - source-url: https://github.com/${{github.repository}}/tree/AssistNow.git + # - source-url: https://github.com/${{github.repository}}.git + - source-path: /tree/AssistNow sketch-paths: | - examples/Example10_AltitudeMSL - examples/Example11_ResetModule/Example1_FactoryDefaultviaI2C From 29b7294ce719834c53651bd28f62fd8f13faef5e Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 11:56:16 +0000 Subject: [PATCH 07/13] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index d0dbb79..28670c1 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -97,7 +97,7 @@ jobs: platforms: ${{ matrix.board.platforms }} fqbn: ${{ matrix.board.fqbn }} libraries: | - # - source-url: https://github.com/${{github.repository}}.git + - source-url: https://github.com/${{github.repository}}.git - source-path: /tree/AssistNow sketch-paths: | - examples/Example10_AltitudeMSL From b7b366673b8a61268ca665916267343aa55dcf09 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 11:59:54 +0000 Subject: [PATCH 08/13] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index 28670c1..78b1457 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -98,7 +98,7 @@ jobs: fqbn: ${{ matrix.board.fqbn }} libraries: | - source-url: https://github.com/${{github.repository}}.git - - source-path: /tree/AssistNow + - source-path: ${{github.ref[11:]}} sketch-paths: | - examples/Example10_AltitudeMSL - examples/Example11_ResetModule/Example1_FactoryDefaultviaI2C From b2ca3e23600c235a4f1e47497f1a410b7fa0a28c Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 12:24:56 +0000 Subject: [PATCH 09/13] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index 78b1457..65354a1 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -97,8 +97,7 @@ jobs: platforms: ${{ matrix.board.platforms }} fqbn: ${{ matrix.board.fqbn }} libraries: | - - source-url: https://github.com/${{github.repository}}.git - - source-path: ${{github.ref[11:]}} + - source-path: ./ sketch-paths: | - examples/Example10_AltitudeMSL - examples/Example11_ResetModule/Example1_FactoryDefaultviaI2C From 3a49e47347d0dc3310a9f0bb503ed7823e230d8f Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 12:37:44 +0000 Subject: [PATCH 10/13] Deliberately re-introduce a compiler warning - just to test the yml --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 391355e..744d716 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -3164,7 +3164,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::sendCommand(ubxPacket *outgoingUBX, uint16_t //Returns false if sensor fails to respond to I2C traffic sfe_ublox_status_e SFE_UBLOX_GNSS::sendI2cCommand(ubxPacket *outgoingUBX, uint16_t maxWait) { - uint16_t ignoreMe = maxWait; ignoreMe += 0; // Do something with maxWait just to avoid the pesky compiler warnings! + //uint16_t ignoreMe = maxWait; ignoreMe += 0; // Do something with maxWait just to avoid the pesky compiler warnings! // From the integration guide: // "The receiver does not provide any write access except for writing UBX and NMEA messages to the From 2b4330a42a899011fad6ff9cefd455cd5a9305d7 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 12:40:05 +0000 Subject: [PATCH 11/13] Revert "Deliberately re-introduce a compiler warning - just to test the yml" This reverts commit 3a49e47347d0dc3310a9f0bb503ed7823e230d8f. --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 744d716..391355e 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -3164,7 +3164,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::sendCommand(ubxPacket *outgoingUBX, uint16_t //Returns false if sensor fails to respond to I2C traffic sfe_ublox_status_e SFE_UBLOX_GNSS::sendI2cCommand(ubxPacket *outgoingUBX, uint16_t maxWait) { - //uint16_t ignoreMe = maxWait; ignoreMe += 0; // Do something with maxWait just to avoid the pesky compiler warnings! + uint16_t ignoreMe = maxWait; ignoreMe += 0; // Do something with maxWait just to avoid the pesky compiler warnings! // From the integration guide: // "The receiver does not provide any write access except for writing UBX and NMEA messages to the From 3cab7acd3f0fcfaa1445936498e6b4db93685382 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 12:44:00 +0000 Subject: [PATCH 12/13] yml: enable-deltas-report; disable compile on push --- .github/workflows/compile-sketch.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index 65354a1..8a225b7 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -1,7 +1,7 @@ name: Compile Sketch on: - - push + # - push - pull_request @@ -110,6 +110,7 @@ jobs: - examples/Example19_DynamicModel - examples/Example20_SendCustomCommand enable-warnings-report: true + enable-deltas-report: true # verbose: true # outputs: From 38440b5a0b96f856991809dfb2dcf6d84cccaa99 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 2 Dec 2021 12:44:51 +0000 Subject: [PATCH 13/13] v2.1.1 --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 08eb80d..2201468 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun u-blox GNSS Arduino Library -version=2.1.0 +version=2.1.1 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for I2C and Serial Communication with u-blox GNSS modules