From ec4a7c4a3758e120ee569cf527c8dc52a142bb45 Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Wed, 8 Dec 2021 14:00:03 -0700 Subject: [PATCH 1/6] Add maxWait to begin functions --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 24 ++++++++++---------- src/SparkFun_u-blox_GNSS_Arduino_Library.h | 6 ++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 68130fa..ecf50f1 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -406,7 +406,7 @@ void SFE_UBLOX_GNSS::setPacketCfgPayloadSize(size_t payloadSize) } //Initialize the I2C port -bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress) +bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t maxWait) { commType = COMM_TYPE_I2C; _i2cPort = &wirePort; //Grab which port the user wants us to use @@ -429,19 +429,19 @@ bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress) createFileBuffer(); // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored - bool connected = isConnected(); + bool connected = isConnected(maxWait); if (!connected) - connected = isConnected(); + connected = isConnected(maxWait); if (!connected) - connected = isConnected(); + connected = isConnected(maxWait); return (connected); } //Initialize the Serial port -bool SFE_UBLOX_GNSS::begin(Stream &serialPort) +bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait) { commType = COMM_TYPE_SERIAL; _serialPort = &serialPort; //Grab which port the user wants us to use @@ -454,19 +454,19 @@ bool SFE_UBLOX_GNSS::begin(Stream &serialPort) createFileBuffer(); // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored - bool connected = isConnected(); + bool connected = isConnected(maxWait); if (!connected) - connected = isConnected(); + connected = isConnected(maxWait); if (!connected) - connected = isConnected(); + connected = isConnected(maxWait); return (connected); } // Initialize for SPI -bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed) +bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait) { commType = COMM_TYPE_SPI; _spiPort = &spiPort; @@ -507,13 +507,13 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed) } // Call isConnected up to three times - bool connected = isConnected(); + bool connected = isConnected(maxWait); if (!connected) - connected = isConnected(); + connected = isConnected(maxWait); if (!connected) - connected = isConnected(); + connected = isConnected(maxWait); return (connected); } diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index 1bc37b9..6a1740b 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -576,11 +576,11 @@ class SFE_UBLOX_GNSS void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize //By default use the default I2C address, and use Wire port - bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42); //Returns true if module is detected + bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait); //Returns true if module is detected //serialPort needs to be perviously initialized to correct baud rate - bool begin(Stream &serialPort); //Returns true if module is detected + bool begin(Stream &serialPort, uint16_t maxWait); //Returns true if module is detected //SPI - supply instance of SPIClass, chip select pin and SPI speed (in Hz) - bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed); + bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait); void end(void); //Stop all automatic message processing. Free all used RAM From d47d02a351a19b2fae9090dccb69b030ab459111 Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Wed, 8 Dec 2021 14:00:58 -0700 Subject: [PATCH 2/6] Add defaults --- src/SparkFun_u-blox_GNSS_Arduino_Library.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index 6a1740b..a3946df 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -576,11 +576,11 @@ class SFE_UBLOX_GNSS void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize //By default use the default I2C address, and use Wire port - bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait); //Returns true if module is detected + bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait = 1100); //Returns true if module is detected //serialPort needs to be perviously initialized to correct baud rate - bool begin(Stream &serialPort, uint16_t maxWait); //Returns true if module is detected + bool begin(Stream &serialPort, uint16_t maxWait = 1100); //Returns true if module is detected //SPI - supply instance of SPIClass, chip select pin and SPI speed (in Hz) - bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait); + bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait = 1100); void end(void); //Stop all automatic message processing. Free all used RAM From 7c799210a81d5883e3e33f62862f061b13617de2 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 9 Dec 2021 11:59:27 +0000 Subject: [PATCH 3/6] Change hard-coded maxWait's to defaultMaxWait --- src/SparkFun_u-blox_GNSS_Arduino_Library.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index 5448fe1..e0f866e 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -599,11 +599,11 @@ class SFE_UBLOX_GNSS void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize //By default use the default I2C address, and use Wire port - bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait = 1100); //Returns true if module is detected + bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait = defaultMaxWait); //Returns true if module is detected //serialPort needs to be perviously initialized to correct baud rate - bool begin(Stream &serialPort, uint16_t maxWait = 1100); //Returns true if module is detected + bool begin(Stream &serialPort, uint16_t maxWait = defaultMaxWait); //Returns true if module is detected //SPI - supply instance of SPIClass, chip select pin and SPI speed (in Hz) - bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait = 1100); + bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait = defaultMaxWait); void end(void); //Stop all automatic message processing. Free all used RAM @@ -633,7 +633,7 @@ class SFE_UBLOX_GNSS int8_t getMaxNMEAByteCount(void); //Returns true if device answers on _gpsI2Caddress address or via Serial - bool isConnected(uint16_t maxWait = 1100); + bool isConnected(uint16_t maxWait = defaultMaxWait); // Enable debug messages using the chosen Serial port (Stream) // Boards like the RedBoard Turbo use SerialUSB (not Serial). @@ -826,7 +826,7 @@ class SFE_UBLOX_GNSS bool powerSaveMode(bool power_save = true, uint16_t maxWait = defaultMaxWait); uint8_t getPowerSaveMode(uint16_t maxWait = defaultMaxWait); // Returns 255 if the sendCommand fails bool powerOff(uint32_t durationInMs, uint16_t maxWait = defaultMaxWait); - bool powerOffWithInterrupt(uint32_t durationInMs, uint32_t wakeupSources = VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0, bool forceWhileUsb = true, uint16_t maxWait = 1100); + bool powerOffWithInterrupt(uint32_t durationInMs, uint32_t wakeupSources = VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0, bool forceWhileUsb = true, uint16_t maxWait = defaultMaxWait); //Change the dynamic platform model using UBX-CFG-NAV5 bool setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = defaultMaxWait); @@ -1235,7 +1235,7 @@ class SFE_UBLOX_GNSS // Helper functions for HPPOSECEF - uint32_t getPositionAccuracy(uint16_t maxWait = 1100); //Returns the 3D accuracy of the current high-precision fix, in mm. Supported on NEO-M8P, ZED-F9P, + uint32_t getPositionAccuracy(uint16_t maxWait = defaultMaxWait); //Returns the 3D accuracy of the current high-precision fix, in mm. Supported on NEO-M8P, ZED-F9P, // Helper functions for HPPOSLLH @@ -1291,8 +1291,8 @@ class SFE_UBLOX_GNSS // Helper functions for HNR - bool setHNRNavigationRate(uint8_t rate, uint16_t maxWait = 1100); // Returns true if the setHNRNavigationRate is successful - uint8_t getHNRNavigationRate(uint16_t maxWait = 1100); // Returns 0 if the getHNRNavigationRate fails + bool setHNRNavigationRate(uint8_t rate, uint16_t maxWait = defaultMaxWait); // Returns true if the setHNRNavigationRate is successful + uint8_t getHNRNavigationRate(uint16_t maxWait = defaultMaxWait); // Returns 0 if the getHNRNavigationRate fails float getHNRroll(uint16_t maxWait = defaultMaxWait); // Returned as degrees float getHNRpitch(uint16_t maxWait = defaultMaxWait); // Returned as degrees float getHNRheading(uint16_t maxWait = defaultMaxWait); // Returned as degrees From 33f5dd2024bedcb2f9036853b728d94bccdbfd47 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 9 Dec 2021 13:10:36 +0000 Subject: [PATCH 4/6] Add softReset as an option for .begin --- keywords.txt | 1 + src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 82 +++++++++++++++++++- src/SparkFun_u-blox_GNSS_Arduino_Library.h | 9 ++- 3 files changed, 84 insertions(+), 8 deletions(-) diff --git a/keywords.txt b/keywords.txt index 60f06f1..3aad233 100644 --- a/keywords.txt +++ b/keywords.txt @@ -121,6 +121,7 @@ setNMEAOutputPort KEYWORD2 factoryReset KEYWORD2 hardReset KEYWORD2 +softwareResetGNSSOnly KEYWORD2 factoryDefault KEYWORD2 saveConfiguration KEYWORD2 diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 6fd38aa..8320188 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -438,7 +438,7 @@ void SFE_UBLOX_GNSS::setPacketCfgPayloadSize(size_t payloadSize) } //Initialize the I2C port -bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t maxWait) +bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t maxWait, bool softReset) { commType = COMM_TYPE_I2C; _i2cPort = &wirePort; //Grab which port the user wants us to use @@ -460,20 +460,40 @@ bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t ma //New in v2.0: allocate memory for the file buffer - if required. (The user should have called setFileBufferSize already) createFileBuffer(); + //Issue a soft reset to clear the buffers + if (softReset) + softwareResetGNSSOnly(); + // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored bool connected = isConnected(maxWait); if (!connected) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - second attempt")); + } +#endif connected = isConnected(maxWait); + } if (!connected) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - third attempt")); + } +#endif connected = isConnected(maxWait); + } return (connected); } //Initialize the Serial port -bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait) +bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait, bool softReset) { commType = COMM_TYPE_SERIAL; _serialPort = &serialPort; //Grab which port the user wants us to use @@ -485,20 +505,40 @@ bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait) //New in v2.0: allocate memory for the file buffer - if required. (The user should have called setFileBufferSize already) createFileBuffer(); + //Issue a soft reset to clear the buffers + if (softReset) + softwareResetGNSSOnly(); + // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored bool connected = isConnected(maxWait); if (!connected) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - second attempt")); + } +#endif connected = isConnected(maxWait); + } if (!connected) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - third attempt")); + } +#endif connected = isConnected(maxWait); + } return (connected); } // Initialize for SPI -bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait) +bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait, bool softReset) { commType = COMM_TYPE_SPI; _spiPort = &spiPort; @@ -538,14 +578,34 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, } } - // Call isConnected up to three times + //Issue a soft reset to clear the buffers + if (softReset) + softwareResetGNSSOnly(); + + // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored bool connected = isConnected(maxWait); if (!connected) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - second attempt")); + } +#endif connected = isConnected(maxWait); + } if (!connected) + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - third attempt")); + } +#endif connected = isConnected(maxWait); + } return (connected); } @@ -5413,6 +5473,20 @@ void SFE_UBLOX_GNSS::hardReset() sendCommand(&packetCfg, 0); // don't expect ACK } +void SFE_UBLOX_GNSS::softwareResetGNSSOnly() +{ + // Issue controlled software reset (GNSS only) + packetCfg.cls = UBX_CLASS_CFG; + packetCfg.id = UBX_CFG_RST; + packetCfg.len = 4; + packetCfg.startingSpot = 0; + payloadCfg[0] = 0; // hot start + payloadCfg[1] = 0; // hot start + payloadCfg[2] = 0x02; // 0x02 = Controlled software reset (GNSS only) + payloadCfg[3] = 0; // reserved + sendCommand(&packetCfg, 0); // don't expect ACK +} + //Reset module to factory defaults //This still works but it is the old way of configuring ublox modules. See getVal and setVal for the new methods bool SFE_UBLOX_GNSS::factoryDefault(uint16_t maxWait) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index e0f866e..e5dbb61 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -599,11 +599,11 @@ class SFE_UBLOX_GNSS void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize //By default use the default I2C address, and use Wire port - bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait = defaultMaxWait); //Returns true if module is detected + bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait = defaultMaxWait, bool softReset = false); //Returns true if module is detected //serialPort needs to be perviously initialized to correct baud rate - bool begin(Stream &serialPort, uint16_t maxWait = defaultMaxWait); //Returns true if module is detected + bool begin(Stream &serialPort, uint16_t maxWait = defaultMaxWait, bool softReset = false); //Returns true if module is detected //SPI - supply instance of SPIClass, chip select pin and SPI speed (in Hz) - bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait = defaultMaxWait); + bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait = defaultMaxWait, bool softReset = false); void end(void); //Stop all automatic message processing. Free all used RAM @@ -780,7 +780,8 @@ class SFE_UBLOX_GNSS void factoryReset(); //Send factory reset sequence (i.e. load "default" configuration and perform hardReset) void hardReset(); //Perform a reset leading to a cold start (zero info start-up) - bool factoryDefault(uint16_t maxWait = defaultMaxWait); //Reset module to factory defaults + void softwareResetGNSSOnly(); //Controlled Software Reset (GNSS only) only restarts the GNSS tasks, without reinitializing the full system or reloading any stored configuration. + bool factoryDefault(uint16_t maxWait = defaultMaxWait); //Reset module to factory defaults //Save configuration to BBR / Flash From 986cdceb945f0fce069b00cefdaa779bc805ab73 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 9 Dec 2021 14:24:52 +0000 Subject: [PATCH 5/6] Add assumeSuccess as a parameter for .begin If you are using Serial, and the module is already outputting messages at high navigation rate, .begin can often fail due to traffic congestion. You can: - use a long maxWait (5 seconds seems to work well) - use a short maxWait and set assumeSuccess to true --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 53 +++++++++++++------- src/SparkFun_u-blox_GNSS_Arduino_Library.h | 7 +-- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 8320188..34419a0 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -438,7 +438,7 @@ void SFE_UBLOX_GNSS::setPacketCfgPayloadSize(size_t payloadSize) } //Initialize the I2C port -bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t maxWait, bool softReset) +bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t maxWait, bool assumeSuccess) { commType = COMM_TYPE_I2C; _i2cPort = &wirePort; //Grab which port the user wants us to use @@ -460,10 +460,6 @@ bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t ma //New in v2.0: allocate memory for the file buffer - if required. (The user should have called setFileBufferSize already) createFileBuffer(); - //Issue a soft reset to clear the buffers - if (softReset) - softwareResetGNSSOnly(); - // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored bool connected = isConnected(maxWait); @@ -489,11 +485,22 @@ bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t ma connected = isConnected(maxWait); } + if ((!connected ) && assumeSuccess) // Advanced users can assume success if required. Useful if the port is outputting messages at high navigation rate. + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: third attempt failed. Assuming success...")); + } +#endif + return (true); + } + return (connected); } //Initialize the Serial port -bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait, bool softReset) +bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait, bool assumeSuccess) { commType = COMM_TYPE_SERIAL; _serialPort = &serialPort; //Grab which port the user wants us to use @@ -505,10 +512,6 @@ bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait, bool softReset) //New in v2.0: allocate memory for the file buffer - if required. (The user should have called setFileBufferSize already) createFileBuffer(); - //Issue a soft reset to clear the buffers - if (softReset) - softwareResetGNSSOnly(); - // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored bool connected = isConnected(maxWait); @@ -534,11 +537,22 @@ bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait, bool softReset) connected = isConnected(maxWait); } + if ((!connected ) && assumeSuccess) // Advanced users can assume success if required. Useful if the port is outputting messages at high navigation rate. + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: third attempt failed. Assuming success...")); + } +#endif + return (true); + } + return (connected); } // Initialize for SPI -bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait, bool softReset) +bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait, bool assumeSuccess) { commType = COMM_TYPE_SPI; _spiPort = &spiPort; @@ -578,10 +592,6 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, } } - //Issue a soft reset to clear the buffers - if (softReset) - softwareResetGNSSOnly(); - // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored bool connected = isConnected(maxWait); @@ -607,6 +617,17 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, connected = isConnected(maxWait); } + if ((!connected ) && assumeSuccess) // Advanced users can assume success if required. Useful if the port is outputting messages at high navigation rate. + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: third attempt failed. Assuming success...")); + } +#endif + return (true); + } + return (connected); } @@ -9702,9 +9723,7 @@ bool SFE_UBLOX_GNSS::getNavigationFrequencyInternal(uint16_t maxWait) return (true); if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN) - { return (true); - } return (false); } diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index e5dbb61..6f5bc92 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -598,12 +598,13 @@ class SFE_UBLOX_GNSS //New in v2.0: allow the payload size for packetCfg to be changed void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize + //Begin communication with the GNSS. Advanced users can assume success if required. Useful if the port is already outputting messages at high navigation rate. //By default use the default I2C address, and use Wire port - bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait = defaultMaxWait, bool softReset = false); //Returns true if module is detected + bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait = defaultMaxWait, bool assumeSuccess = false); //Returns true if module is detected //serialPort needs to be perviously initialized to correct baud rate - bool begin(Stream &serialPort, uint16_t maxWait = defaultMaxWait, bool softReset = false); //Returns true if module is detected + bool begin(Stream &serialPort, uint16_t maxWait = defaultMaxWait, bool assumeSuccess = false); //Returns true if module is detected //SPI - supply instance of SPIClass, chip select pin and SPI speed (in Hz) - bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait = defaultMaxWait, bool softReset = false); + bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait = defaultMaxWait, bool assumeSuccess = false); void end(void); //Stop all automatic message processing. Free all used RAM From 0ecec8b34283904bda8fa3dbc770b8794aed7dd4 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Thu, 9 Dec 2021 14:25:32 +0000 Subject: [PATCH 6/6] v2.1.3 --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index c52c9b2..b06dd6b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun u-blox GNSS Arduino Library -version=2.1.2 +version=2.1.3 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for I2C and Serial Communication with u-blox GNSS modules