Skip to content

v2.2.2 #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void setup()
//The ZED-F9P is slightly different than the NEO-M8P. See the Integration manual 3.5.8 for more info.
//response = myGNSS.enableSurveyMode(300, 2.000); //Enable Survey in on NEO-M8P, 300 seconds, 2.0m
response = myGNSS.enableSurveyMode(60, 5.000); //Enable Survey in, 60 seconds, 5.0m
//response = myGNSS.enableSurveyModeFull(86400, 2.000); //Enable Survey in, 24 hours, 2.0m
if (response == false)
{
Serial.println(F("Survey start failed. Freezing..."));
Expand Down Expand Up @@ -136,14 +137,14 @@ void setup()
// From v2.0, the data from getSurveyStatus (UBX-NAV-SVIN) is returned in UBX_NAV_SVIN_t packetUBXNAVSVIN
// Please see u-blox_structs.h for the full definition of UBX_NAV_SVIN_t
// You can either read the data from packetUBXNAVSVIN directly
// or can use the helper functions: getSurveyInActive; getSurveyInValid; getSurveyInObservationTime; and getSurveyInMeanAccuracy
// or can use the helper functions: getSurveyInActive; getSurveyInValid; getSurveyInObservationTime; getSurveyInObservationTimeFull; and getSurveyInMeanAccuracy
response = myGNSS.getSurveyStatus(2000); //Query module for SVIN status with 2000ms timeout (req can take a long time)

if (response == true) // Check if fresh data was received
{
Serial.print(F("Press x to end survey - "));
Serial.print(F("Time elapsed: "));
Serial.print((String)myGNSS.getSurveyInObservationTime()); // Call the helper function
Serial.print((String)myGNSS.getSurveyInObservationTimeFull()); // Call the helper function
Serial.print(F(" ("));
Serial.print((String)myGNSS.packetUBXNAVSVIN->data.dur); // Read the survey-in duration directly from packetUBXNAVSVIN

Expand Down
3 changes: 3 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ disableRTCMmessage KEYWORD2

getSurveyMode KEYWORD2
setSurveyMode KEYWORD2
setSurveyModeFull KEYWORD2
enableSurveyMode KEYWORD2
enableSurveyModeFull KEYWORD2
disableSurveyMode KEYWORD2
setStaticPosition KEYWORD2
setDGNSSConfiguration KEYWORD2
Expand Down Expand Up @@ -575,6 +577,7 @@ getMotionHeading KEYWORD2
getSurveyInActive KEYWORD2
getSurveyInValid KEYWORD2
getSurveyInObservationTime KEYWORD2
getSurveyInObservationTimeFull KEYWORD2
getSurveyInMeanAccuracy KEYWORD2

getRelPosN KEYWORD2
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun u-blox GNSS Arduino Library
version=2.2.1
version=2.2.2
author=SparkFun Electronics <techsupport@sparkfun.com>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>
Expand Down
36 changes: 24 additions & 12 deletions src/SparkFun_u-blox_GNSS_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6661,6 +6661,10 @@ bool SFE_UBLOX_GNSS::getSurveyMode(uint16_t maxWait)

// Control Survey-In for NEO-M8P
bool SFE_UBLOX_GNSS::setSurveyMode(uint8_t mode, uint16_t observationTime, float requiredAccuracy, uint16_t maxWait)
{
return (setSurveyModeFull(mode, (uint32_t)observationTime, requiredAccuracy, maxWait));
}
bool SFE_UBLOX_GNSS::setSurveyModeFull(uint8_t mode, uint32_t observationTime, float requiredAccuracy, uint16_t maxWait)
{
if (getSurveyMode(maxWait) == false) // Ask module for the current TimeMode3 settings. Loads into payloadCfg.
return (false);
Expand All @@ -6673,26 +6677,30 @@ bool SFE_UBLOX_GNSS::setSurveyMode(uint8_t mode, uint16_t observationTime, float
// payloadCfg should be loaded with poll response. Now modify only the bits we care about
payloadCfg[2] = mode; // Set mode. Survey-In and Disabled are most common. Use ECEF (not LAT/LON/ALT).

// svinMinDur is U4 (uint32_t) but we'll only use a uint16_t (waiting more than 65535 seconds seems excessive!)
// svinMinDur is U4 (uint32_t) in seconds
payloadCfg[24] = observationTime & 0xFF; // svinMinDur in seconds
payloadCfg[25] = observationTime >> 8; // svinMinDur in seconds
payloadCfg[26] = 0; // Truncate to 16 bits
payloadCfg[27] = 0; // Truncate to 16 bits
payloadCfg[25] = (observationTime >> 8) & 0xFF;
payloadCfg[26] = (observationTime >> 16) & 0xFF;
payloadCfg[27] = (observationTime >> 24) & 0xFF;

// svinAccLimit is U4 (uint32_t) in 0.1mm.
uint32_t svinAccLimit = (uint32_t)(requiredAccuracy * 10000.0); // Convert m to 0.1mm
payloadCfg[28] = svinAccLimit & 0xFF; // svinAccLimit in 0.1mm increments
payloadCfg[29] = svinAccLimit >> 8;
payloadCfg[30] = svinAccLimit >> 16;
payloadCfg[31] = svinAccLimit >> 24;
payloadCfg[29] = (svinAccLimit >> 8) & 0xFF;
payloadCfg[30] = (svinAccLimit >> 16) & 0xFF;
payloadCfg[31] = (svinAccLimit >> 24) & 0xFF;

return ((sendCommand(&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
}

// Begin Survey-In for NEO-M8P
bool SFE_UBLOX_GNSS::enableSurveyMode(uint16_t observationTime, float requiredAccuracy, uint16_t maxWait)
{
return (setSurveyMode(SVIN_MODE_ENABLE, observationTime, requiredAccuracy, maxWait));
return (setSurveyModeFull(SVIN_MODE_ENABLE, (uint32_t)observationTime, requiredAccuracy, maxWait));
}
bool SFE_UBLOX_GNSS::enableSurveyModeFull(uint32_t observationTime, float requiredAccuracy, uint16_t maxWait)
{
return (setSurveyModeFull(SVIN_MODE_ENABLE, observationTime, requiredAccuracy, maxWait));
}

// Stop Survey-In for NEO-M8P
Expand Down Expand Up @@ -15554,7 +15562,7 @@ bool SFE_UBLOX_GNSS::getSurveyInValid(uint16_t maxWait)
return ((bool)packetUBXNAVSVIN->data.valid);
}

uint16_t SFE_UBLOX_GNSS::getSurveyInObservationTime(uint16_t maxWait) // Truncated to 65535 seconds
uint32_t SFE_UBLOX_GNSS::getSurveyInObservationTimeFull(uint16_t maxWait) // Return the full uint32_t
{
if (packetUBXNAVSVIN == NULL)
initPacketUBXNAVSVIN(); // Check that RAM has been allocated for the SVIN data
Expand All @@ -15566,9 +15574,13 @@ uint16_t SFE_UBLOX_GNSS::getSurveyInObservationTime(uint16_t maxWait) // Truncat
packetUBXNAVSVIN->moduleQueried.moduleQueried.bits.dur = false; // Since we are about to give this to user, mark this data as stale
packetUBXNAVSVIN->moduleQueried.moduleQueried.bits.all = false;

// dur (Passed survey-in observation time) is U4 (uint32_t) seconds. We truncate to 16 bits
//(waiting more than 65535 seconds (18.2 hours) seems excessive!)
uint32_t tmpObsTime = packetUBXNAVSVIN->data.dur;
return (packetUBXNAVSVIN->data.dur);
}

uint16_t SFE_UBLOX_GNSS::getSurveyInObservationTime(uint16_t maxWait) // Truncated to 65535 seconds
{
// dur (Passed survey-in observation time) is U4 (uint32_t) seconds. Here we truncate to 16 bits
uint32_t tmpObsTime = getSurveyInObservationTimeFull(maxWait);
if (tmpObsTime <= 0xFFFF)
{
return ((uint16_t)tmpObsTime);
Expand Down
25 changes: 19 additions & 6 deletions src/SparkFun_u-blox_GNSS_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const uint8_t UBX_CLASS_LOG = 0x21; // Logging Messages: Log creation, deletion
const uint8_t UBX_CLASS_SEC = 0x27; // Security Feature Messages
const uint8_t UBX_CLASS_HNR = 0x28; //(NEO-M8P ONLY!!!) High Rate Navigation Results Messages: High rate time, position speed, heading
const uint8_t UBX_CLASS_NMEA = 0xF0; // NMEA Strings: standard NMEA strings
const uint8_t UBX_CLASS_PUBX = 0xF1; // Proprietary NMEA-format messages defined by u-blox

// Class: CFG
// The following are used for configuration. Descriptions are from the ZED-F9P Interface Description pg 33-34 and NEO-M9N Interface Description pg 47-48
Expand Down Expand Up @@ -265,6 +266,15 @@ const uint8_t UBX_NMEA_MAINTALKERID_GB = 0x05; // main talker ID is B
const uint8_t UBX_NMEA_GSVTALKERID_GNSS = 0x00; // GNSS specific Talker ID (as defined by NMEA)
const uint8_t UBX_NMEA_GSVTALKERID_MAIN = 0x01; // use the main Talker ID

// Class: PUBX
// The following are used to enable PUBX messages with configureMessage
// See the M8 receiver description & protocol specification for more details
const uint8_t UBX_PUBX_CONFIG = 0x41; // Set protocols and baud rate
const uint8_t UBX_PUBX_POSITION = 0x00; // Lat/Long position data
const uint8_t UBX_PUBX_RATE = 0x40; // Set/get NMEA message output rate
const uint8_t UBX_PUBX_SVSTATUS = 0x03; // Satellite status
const uint8_t UBX_PUBX_TIME = 0x04; // Time of day and clock information

// Class: HNR
// The following are used to configure the HNR message rates
const uint8_t UBX_HNR_ATT = 0x01; // HNR Attitude
Expand Down Expand Up @@ -834,10 +844,12 @@ class SFE_UBLOX_GNSS

// Functions used for RTK and base station setup
// It is probably safe to assume that users of the RTK will be using I2C / Qwiic. So let's leave maxWait set to 250ms.
bool getSurveyMode(uint16_t maxWait = 250); // Get the current TimeMode3 settings
bool setSurveyMode(uint8_t mode, uint16_t observationTime, float requiredAccuracy, uint16_t maxWait = 250); // Control survey in mode
bool enableSurveyMode(uint16_t observationTime, float requiredAccuracy, uint16_t maxWait = 250); // Begin Survey-In for NEO-M8P
bool disableSurveyMode(uint16_t maxWait = 250); // Stop Survey-In mode
bool getSurveyMode(uint16_t maxWait = 250); // Get the current TimeMode3 settings
bool setSurveyMode(uint8_t mode, uint16_t observationTime, float requiredAccuracy, uint16_t maxWait = 250); // Control survey in mode
bool setSurveyModeFull(uint8_t mode, uint32_t observationTime, float requiredAccuracy, uint16_t maxWait = 250); // Control survey in mode
bool enableSurveyMode(uint16_t observationTime, float requiredAccuracy, uint16_t maxWait = 250); // Begin Survey-In for NEO-M8P / ZED-F9x
bool enableSurveyModeFull(uint32_t observationTime, float requiredAccuracy, uint16_t maxWait = 250); // Begin Survey-In for NEO-M8P / ZED-F9x
bool disableSurveyMode(uint16_t maxWait = 250); // Stop Survey-In mode
// Given coordinates, put receiver into static position. Set latlong to true to pass in lat/long values instead of ecef.
// For ECEF the units are: cm, 0.1mm, cm, 0.1mm, cm, 0.1mm
// For Lat/Lon/Alt the units are: degrees^-7, degrees^-9, degrees^-7, degrees^-9, cm, 0.1mm
Expand Down Expand Up @@ -1352,8 +1364,9 @@ class SFE_UBLOX_GNSS

bool getSurveyInActive(uint16_t maxWait = defaultMaxWait);
bool getSurveyInValid(uint16_t maxWait = defaultMaxWait);
uint16_t getSurveyInObservationTime(uint16_t maxWait = defaultMaxWait); // Truncated to 65535 seconds
float getSurveyInMeanAccuracy(uint16_t maxWait = defaultMaxWait); // Returned as m
uint16_t getSurveyInObservationTime(uint16_t maxWait = defaultMaxWait); // Truncated to 65535 seconds
uint32_t getSurveyInObservationTimeFull(uint16_t maxWait = defaultMaxWait); // Return the full uint32_t
float getSurveyInMeanAccuracy(uint16_t maxWait = defaultMaxWait); // Returned as m

// Helper functions for TIMELS

Expand Down
4 changes: 2 additions & 2 deletions src/u-blox_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2129,8 +2129,8 @@ typedef struct
uint8_t dbdEntryChecksumB;
} UBX_MGA_DBD_data_t;

#if defined(ARDUINO_ARCH_AVR)
#define UBX_MGA_DBD_RINGBUFFER_LEN 190 // Fix to let the code compile on AVR platforms - including the UNO.
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR)
#define UBX_MGA_DBD_RINGBUFFER_LEN 190 // Fix to let the code compile on AVR platforms - including the UNO and DxCore (DA/DB).
#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
Expand Down