Skip to content

Commit fda2568

Browse files
committed
Add code safety comments for methods that could return junk if the get fails
1 parent 165e98a commit fda2568

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/u-blox_GNSS.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,15 @@ class DevUBLOXGNSS
386386
bool setDGNSSConfiguration(sfe_ublox_dgnss_mode_e dgnssMode = SFE_UBLOX_DGNSS_MODE_FIXED, uint8_t layer = VAL_LAYER_RAM_BBR, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Set the DGNSS differential mode
387387

388388
// Read the module's protocol version
389+
// For safety, call getProtocolVersion etc. inside an if(getModuleInfo())
389390
uint8_t getProtocolVersionHigh(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the PROTVER XX.00 from UBX-MON-VER register
390391
uint8_t getProtocolVersionLow(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the PROTVER 00.XX from UBX-MON-VER register
391392
uint8_t getFirmwareVersionHigh(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the FWVER XX.00 from UBX-MON-VER register
392393
uint8_t getFirmwareVersionLow(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the FWVER 00.XX from UBX-MON-VER register
393394
const char *getFirmwareType(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the firmware type (SPG, HPG, ADR, etc.) from UBX-MON-VER register
394395
const char *getModuleName(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the module name (ZED-F9P, ZED-F9R, etc.) from UBX-MON-VER register
395396
bool getProtocolVersion(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Deprecated. Use getModuleInfo.
396-
bool getModuleInfo(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Queries module, extracts info
397+
bool getModuleInfo(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Queries module, extracts info. Returns true if MON-VER was read successfully
397398
protected:
398399
bool prepareModuleInfo(uint16_t maxWait);
399400

@@ -1078,6 +1079,7 @@ class DevUBLOXGNSS
10781079
uint16_t getNavigationRate(uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Unsafe overload
10791080

10801081
// Helper functions for DOP
1082+
// For safety, call these inside an if(getDOP())
10811083

10821084
uint16_t getGeometricDOP(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
10831085
uint16_t getPositionDOP(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
@@ -1088,12 +1090,14 @@ class DevUBLOXGNSS
10881090
uint16_t getEastingDOP(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
10891091

10901092
// Helper functions for ATT
1093+
// For safety, call these inside an if(getNAVATT())
10911094

10921095
float getATTroll(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returned as degrees
10931096
float getATTpitch(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returned as degrees
10941097
float getATTheading(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returned as degrees
10951098

10961099
// Helper functions for PVT
1100+
// For safety, call these inside an if(getPVT())
10971101

10981102
uint32_t getTimeOfWeek(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
10991103
uint16_t getYear(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
@@ -1145,6 +1149,7 @@ class DevUBLOXGNSS
11451149
int32_t getGeoidSeparation(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
11461150

11471151
// Helper functions for HPPOSECEF
1152+
// For safety, call these inside an if(getNAVHPPOSECEF())
11481153

11491154
uint32_t getPositionAccuracy(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the 3D accuracy of the current high-precision fix, in mm. Supported on NEO-M8P, ZED-F9P,
11501155
int32_t getHighResECEFX(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the ECEF X coordinate (cm)
@@ -1155,6 +1160,7 @@ class DevUBLOXGNSS
11551160
int8_t getHighResECEFZHp(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the ECEF Z coordinate High Precision Component (0.1 mm)
11561161

11571162
// Helper functions for HPPOSLLH
1163+
// For safety, call these inside an if(getHPPOSLLH())
11581164

11591165
uint32_t getTimeOfWeekFromHPPOSLLH(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
11601166
int32_t getHighResLongitude(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
@@ -1169,13 +1175,15 @@ class DevUBLOXGNSS
11691175
uint32_t getVerticalAccuracy(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
11701176

11711177
// Helper functions for PVAT
1178+
// For safety, call these inside an if(getNAVPVAT())
11721179

11731180
int32_t getVehicleRoll(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns vehicle roll in degrees * 10^-5
11741181
int32_t getVehiclePitch(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns vehicle pitch in degrees * 10^-5
11751182
int32_t getVehicleHeading(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns vehicle heading in degrees * 10^-5
11761183
int32_t getMotionHeading(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the motion heading in degrees * 10^-5
11771184

11781185
// Helper functions for SVIN
1186+
// For safety, call these inside an if(getSurveyStatus())
11791187

11801188
bool getSurveyInActive(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
11811189
bool getSurveyInValid(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
@@ -1184,11 +1192,13 @@ class DevUBLOXGNSS
11841192
float getSurveyInMeanAccuracy(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returned as m
11851193

11861194
// Helper functions for TIMELS
1195+
// For safety, call these inside an if(getLeapSecondEvent())
11871196

11881197
uint8_t getLeapIndicator(int32_t &timeToLsEvent, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
11891198
int8_t getCurrentLeapSeconds(sfe_ublox_ls_src_e &source, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait);
11901199

11911200
// Helper functions for RELPOSNED
1201+
// For safety, call these inside an if(getRELPOSNED())
11921202

11931203
float getRelPosN(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returned as m
11941204
float getRelPosE(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returned as m
@@ -1198,24 +1208,28 @@ class DevUBLOXGNSS
11981208
float getRelPosAccD(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returned as m
11991209

12001210
// Helper functions for AOPSTATUS
1211+
// For safety, call these inside an if(getAOPSTATUS())
12011212

12021213
uint8_t getAOPSTATUSuseAOP(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the UBX-NAV-AOPSTATUS useAOP flag. Don't confuse this with getAopCfg - which returns the aopCfg byte from UBX-CFG-NAVX5
12031214
uint8_t getAOPSTATUSstatus(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the UBX-NAV-AOPSTATUS status field. A host application can determine the optimal time to shut down the receiver by monitoring the status field for a steady 0.
12041215

12051216
// Helper functions for TIM TP
1217+
// For safety, call these inside an if(getTIMTP())
12061218

12071219
uint32_t getTIMTPtowMS(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the UBX-TIM-TP towMS time pulse of week (ms)
12081220
uint32_t getTIMTPtowSubMS(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the UBX-TIM-TP submillisecond part of towMS (ms * 2^-32)
12091221
uint16_t getTIMTPweek(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns the UBX-TIM-TP time pulse week according to time base
12101222
uint32_t getTIMTPAsEpoch(uint32_t &microsecond, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Convert TIM TP to Unix Epoch - CAUTION! Assumes the time base is UTC and the week number is GPS
12111223

12121224
// Helper function for hardware status (including jamming)
1225+
// For safety, call getAntennaStatus inside an if(getMONHW())
12131226

12141227
bool getHWstatus(UBX_MON_HW_data_t *data = nullptr, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Get the hardware status using UBX_MON_HW
12151228
sfe_ublox_antenna_status_e getAntennaStatus(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Get the antenna status (aStatus) using UBX_MON_HW
12161229

12171230
#ifndef SFE_UBLOX_DISABLE_ESF
12181231
// Helper functions for ESF
1232+
// For safety, call getESFroll/pitch/yaw inside an if(getESFALG())
12191233

12201234
float getESFroll(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returned as degrees
12211235
float getESFpitch(uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returned as degrees
@@ -1228,6 +1242,7 @@ class DevUBLOXGNSS
12281242

12291243
#ifndef SFE_UBLOX_DISABLE_HNR
12301244
// Helper functions for HNR
1245+
// For safety, call getHNRroll/pitch/yaw inside an if(getHNRATT())
12311246

12321247
bool setHNRNavigationRate(uint8_t rate, uint8_t layer = VAL_LAYER_RAM_BBR, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns true if the setHNRNavigationRate is successful
12331248
uint8_t getHNRNavigationRate(uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = kUBLOXGNSSDefaultMaxWait); // Returns 0 if the getHNRNavigationRate fails

0 commit comments

Comments
 (0)