@@ -2005,15 +2005,20 @@ boolean SFE_UBLOX_GPS::setSurveyMode(uint8_t mode, uint16_t observationTime, flo
2005
2005
packetCfg.payload [x] = 0 ;
2006
2006
2007
2007
// payloadCfg should be loaded with poll response. Now modify only the bits we care about
2008
- payloadCfg[2 ] = mode; // Set mode. Survey-In and Disabled are most common.
2008
+ payloadCfg[2 ] = mode; // Set mode. Survey-In and Disabled are most common. Use ECEF (not LAT/LON/ALT).
2009
2009
2010
+ // svinMinDur is U4 (uint32_t) but we'll only use a uint16_t (waiting more than 65535 seconds seems excessive!)
2010
2011
payloadCfg[24 ] = observationTime & 0xFF ; // svinMinDur in seconds
2011
2012
payloadCfg[25 ] = observationTime >> 8 ; // svinMinDur in seconds
2013
+ payloadCfg[26 ] = 0 ; // Truncate to 16 bits
2014
+ payloadCfg[27 ] = 0 ; // Truncate to 16 bits
2012
2015
2013
- uint32_t svinAccLimit = requiredAccuracy * 10000 ; // Convert m to 0.1mm
2016
+ // svinAccLimit is U4 (uint32_t) in 0.1mm.
2017
+ uint32_t svinAccLimit = (uint32_t )(requiredAccuracy * 10000.0 ); // Convert m to 0.1mm
2014
2018
payloadCfg[28 ] = svinAccLimit & 0xFF ; // svinAccLimit in 0.1mm increments
2015
2019
payloadCfg[29 ] = svinAccLimit >> 8 ;
2016
2020
payloadCfg[30 ] = svinAccLimit >> 16 ;
2021
+ payloadCfg[31 ] = svinAccLimit >> 24 ;
2017
2022
2018
2023
return ((sendCommand (&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
2019
2024
}
@@ -2050,13 +2055,25 @@ boolean SFE_UBLOX_GPS::getSurveyStatus(uint16_t maxWait)
2050
2055
return (false ); // If command send fails then bail
2051
2056
2052
2057
// We got a response, now parse the bits into the svin structure
2053
- svin.observationTime = extractLong (8 );
2054
2058
2059
+ // dur (Passed survey-in observation time) is U4 (uint32_t) seconds. We truncate to 16 bits
2060
+ // (waiting more than 65535 seconds (18.2 hours) seems excessive!)
2061
+ uint32_t tmpObsTime = extractLong (8 );
2062
+ if (tmpObsTime <= 0xFFFF )
2063
+ {
2064
+ svin.observationTime = (uint16_t )tmpObsTime;
2065
+ }
2066
+ else
2067
+ {
2068
+ svin.observationTime = 0xFFFF ;
2069
+ }
2070
+
2071
+ // meanAcc is U4 (uint32_t) in 0.1mm. We convert this to float.
2055
2072
uint32_t tempFloat = extractLong (28 );
2056
- svin.meanAccuracy = tempFloat / 10000.0 ; // Convert 0.1mm to m
2073
+ svin.meanAccuracy = (( float ) tempFloat) / 10000.0 ; // Convert 0.1mm to m
2057
2074
2058
- svin.valid = payloadCfg[36 ];
2059
- svin.active = payloadCfg[37 ]; // 1 if survey in progress, 0 otherwise
2075
+ svin.valid = payloadCfg[36 ]; // 1 if survey-in position is valid, 0 otherwise
2076
+ svin.active = payloadCfg[37 ]; // 1 if survey-in in progress, 0 otherwise
2060
2077
2061
2078
return (true );
2062
2079
}
0 commit comments