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
This commit is contained in:
@@ -438,7 +438,7 @@ void SFE_UBLOX_GNSS::setPacketCfgPayloadSize(size_t payloadSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Initialize the I2C port
|
//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;
|
commType = COMM_TYPE_I2C;
|
||||||
_i2cPort = &wirePort; //Grab which port the user wants us to use
|
_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)
|
//New in v2.0: allocate memory for the file buffer - if required. (The user should have called setFileBufferSize already)
|
||||||
createFileBuffer();
|
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
|
// Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored
|
||||||
bool connected = isConnected(maxWait);
|
bool connected = isConnected(maxWait);
|
||||||
|
|
||||||
@@ -489,11 +485,22 @@ bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t ma
|
|||||||
connected = isConnected(maxWait);
|
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);
|
return (connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Initialize the Serial port
|
//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;
|
commType = COMM_TYPE_SERIAL;
|
||||||
_serialPort = &serialPort; //Grab which port the user wants us to use
|
_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)
|
//New in v2.0: allocate memory for the file buffer - if required. (The user should have called setFileBufferSize already)
|
||||||
createFileBuffer();
|
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
|
// Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored
|
||||||
bool connected = isConnected(maxWait);
|
bool connected = isConnected(maxWait);
|
||||||
|
|
||||||
@@ -534,11 +537,22 @@ bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait, bool softReset)
|
|||||||
connected = isConnected(maxWait);
|
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);
|
return (connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize for SPI
|
// 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;
|
commType = COMM_TYPE_SPI;
|
||||||
_spiPort = &spiPort;
|
_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
|
// Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored
|
||||||
bool connected = isConnected(maxWait);
|
bool connected = isConnected(maxWait);
|
||||||
|
|
||||||
@@ -607,6 +617,17 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed,
|
|||||||
connected = isConnected(maxWait);
|
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);
|
return (connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9702,9 +9723,7 @@ bool SFE_UBLOX_GNSS::getNavigationFrequencyInternal(uint16_t maxWait)
|
|||||||
return (true);
|
return (true);
|
||||||
|
|
||||||
if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
|
if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
|
||||||
{
|
|
||||||
return (true);
|
return (true);
|
||||||
}
|
|
||||||
|
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -598,12 +598,13 @@ public:
|
|||||||
//New in v2.0: allow the payload size for packetCfg to be changed
|
//New in v2.0: allow the payload size for packetCfg to be changed
|
||||||
void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize
|
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
|
//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
|
//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)
|
//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
|
void end(void); //Stop all automatic message processing. Free all used RAM
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user