Skip to content

Commit e0c0c94

Browse files
committed
Increase timeouts to rover and base config.
At 4Hz fully logging, I2C bus is busy. Give config commands increased maxWaits.
1 parent 69b98f3 commit e0c0c94

File tree

3 files changed

+102
-67
lines changed

3 files changed

+102
-67
lines changed

Firmware/RTK_Surveyor/Base.ino

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,32 @@
33
bool configureUbloxModuleBase()
44
{
55
bool response = true;
6+
int maxWait = 2000;
67

78
digitalWrite(positionAccuracyLED_1cm, LOW);
89
digitalWrite(positionAccuracyLED_10cm, LOW);
910
digitalWrite(positionAccuracyLED_100cm, LOW);
1011

12+
i2cGNSS.checkUblox(); //Regularly poll to get latest data and any RTCM
13+
1114
//In base mode we force 1Hz
12-
if (i2cGNSS.getNavigationFrequency() != 1)
15+
if (i2cGNSS.getNavigationFrequency(maxWait) != 1)
16+
response &= i2cGNSS.setNavigationFrequency(1, maxWait);
17+
if (response == false)
1318
{
14-
response &= i2cGNSS.setNavigationFrequency(1); //Set output in Hz
19+
Serial.println(F("configureUbloxModuleBase: Set rate failed"));
20+
return (false);
1521
}
1622

1723
// Set dynamic model
18-
if (i2cGNSS.getDynamicModel() != DYN_MODEL_STATIONARY)
24+
if (i2cGNSS.getDynamicModel(maxWait) != DYN_MODEL_STATIONARY)
1925
{
20-
response &= i2cGNSS.setDynamicModel(DYN_MODEL_STATIONARY);
26+
response &= i2cGNSS.setDynamicModel(DYN_MODEL_STATIONARY, maxWait);
2127
if (response == false)
22-
Serial.println(F("setDynamicModel failed!"));
28+
{
29+
Serial.println(F("setDynamicModel failed"));
30+
return (false);
31+
}
2332
}
2433

2534
//In base mode the Surveyor should output RTCM over UART2 and I2C ports:
@@ -30,30 +39,13 @@ bool configureUbloxModuleBase()
3039
response &= enableRTCMSentences(COM_PORT_UART2);
3140
response &= enableRTCMSentences(COM_PORT_UART1);
3241
response &= enableRTCMSentences(COM_PORT_USB);
33-
34-
if (settings.enableNtripServer == true)
35-
{
36-
//Turn on RTCM over I2C port so that we can harvest RTCM over I2C and send out over WiFi
37-
//This is easier than parsing over UART because the library handles the frame detection
38-
39-
#define OUTPUT_SETTING 14
40-
#define INPUT_SETTING 12
41-
getPortSettings(COM_PORT_I2C); //Load the settingPayload with this port's settings
42-
if (settingPayload[OUTPUT_SETTING] != COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3 || settingPayload[INPUT_SETTING] != COM_TYPE_UBX)
43-
{
44-
response &= i2cGNSS.setPortOutput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3); //UBX+RTCM3 is not a valid option so we enable all three.
45-
response &= i2cGNSS.setPortInput(COM_PORT_I2C, COM_TYPE_UBX); //Set the I2C port to input UBX only
46-
}
47-
48-
//Disable any NMEA sentences
49-
response &= disableNMEASentences(COM_PORT_I2C);
50-
51-
//Enable necessary RTCM sentences
52-
response &= enableRTCMSentences(COM_PORT_I2C);
53-
}
42+
response &= enableRTCMSentences(COM_PORT_I2C); //Enable for plain radio so we can count RTCM packets for display (State: Base-Temp - Transmitting)
5443

5544
if (response == false)
45+
{
5646
Serial.println(F("RTCM settings failed to enable"));
47+
return (false);
48+
}
5749

5850
return (response);
5951
}
@@ -62,7 +54,21 @@ bool configureUbloxModuleBase()
6254
//The ZED-F9P is slightly different than the NEO-M8P. See the Integration manual 3.5.8 for more info.
6355
bool surveyIn()
6456
{
65-
resetSurvey();
57+
bool needSurveyReset = false;
58+
if (i2cGNSS.getSurveyInActive == true) needSurveyReset = true;
59+
if (i2cGNSS.getSurveyInValid == true) needSurveyReset = true;
60+
61+
if (needSurveyReset == true)
62+
{
63+
if (resetSurvey() == false)
64+
{
65+
Serial.println(F("Survey reset failed"));
66+
if (resetSurvey() == false)
67+
{
68+
Serial.println(F("Survey reset failed - 2nd attempt"));
69+
}
70+
}
71+
}
6672

6773
bool response = i2cGNSS.enableSurveyMode(settings.observationSeconds, settings.observationPositionAccuracy); //Enable Survey in, with user parameters
6874
if (response == false)
@@ -79,15 +85,18 @@ bool surveyIn()
7985
return (true);
8086
}
8187

82-
void resetSurvey()
88+
bool resetSurvey()
8389
{
90+
int maxWait = 2000;
91+
8492
//Slightly modified method for restarting survey-in from: https://portal.u-blox.com/s/question/0D52p00009IsVoMCAV/restarting-surveyin-on-an-f9p
85-
bool response = i2cGNSS.disableSurveyMode(); //Disable survey
86-
delay(500);
87-
response &= i2cGNSS.enableSurveyMode(1000, 400.000); //Enable Survey in with bogus values
88-
delay(500);
89-
response &= i2cGNSS.disableSurveyMode(); //Disable survey
90-
delay(500);
93+
bool response = i2cGNSS.disableSurveyMode(maxWait); //Disable survey
94+
delay(1000);
95+
response &= i2cGNSS.enableSurveyMode(1000, 400.000, maxWait); //Enable Survey in with bogus values
96+
delay(1000);
97+
response &= i2cGNSS.disableSurveyMode(maxWait); //Disable survey
98+
delay(1000);
99+
return (response);
91100
}
92101

93102
//Start the base using fixed coordinates

Firmware/RTK_Surveyor/Rover.ino

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,53 @@
22
//Configure specific aspects of the receiver for rover mode
33
bool configureUbloxModuleRover()
44
{
5-
bool response = i2cGNSS.disableSurveyMode(); //Disable survey
6-
7-
//Set output rate
8-
if (i2cGNSS.getMeasurementRate() != settings.measurementRate)
9-
{
10-
response &= i2cGNSS.setMeasurementRate(settings.measurementRate);
11-
}
12-
if (i2cGNSS.getNavigationRate() != settings.navigationRate)
13-
{
14-
response &= i2cGNSS.getNavigationRate(settings.navigationRate);
15-
}
5+
bool response = true;
6+
7+
response = i2cGNSS.disableSurveyMode(); //Disable survey
8+
if (response == false)
9+
Serial.println(F("Disable Survey failed"));
1610

1711
// Set dynamic model
1812
if (i2cGNSS.getDynamicModel() != DYN_MODEL_PORTABLE)
1913
{
20-
response &= i2cGNSS.setDynamicModel(DYN_MODEL_PORTABLE);
14+
response = i2cGNSS.setDynamicModel(DYN_MODEL_PORTABLE, 1000);
2115
if (response == false)
22-
Serial.println(F("setDynamicModel failed!"));
16+
Serial.println(F("setDynamicModel failed"));
2317
}
2418

2519
//Disable RTCM sentences
20+
response = true; //Reset
2621
response &= disableRTCMSentences(COM_PORT_I2C);
2722
response &= disableRTCMSentences(COM_PORT_UART2);
2823
response &= disableRTCMSentences(COM_PORT_UART1);
2924
response &= disableRTCMSentences(COM_PORT_USB);
3025
if (response == false)
3126
Serial.println(F("Disable RTCM failed"));
3227

33-
response &= setNMEASettings(); //Enable high precision NMEA and extended sentences
28+
response = setNMEASettings(); //Enable high precision NMEA and extended sentences
29+
if (response == false)
30+
Serial.println(F("setNMEASettings failed"));
3431

32+
response = true; //Reset
3533
if (settings.enableSBAS == true)
3634
response &= setSBAS(true); //Enable SBAS
3735
else
3836
response &= setSBAS(false); //Disable SBAS. Work around for RTK LED not working in v1.13 firmware.
37+
if (response == false)
38+
Serial.println(F("Set SBAS failed"));
39+
40+
//The last thing we do is set output rate.
41+
response = true; //Reset
42+
if (i2cGNSS.getMeasurementRate() != settings.measurementRate)
43+
{
44+
response &= i2cGNSS.setMeasurementRate(settings.measurementRate);
45+
}
46+
if (i2cGNSS.getNavigationRate() != settings.navigationRate)
47+
{
48+
response &= i2cGNSS.setNavigationRate(settings.navigationRate);
49+
}
50+
if (response == false)
51+
Serial.println(F("Set Nav Rate failed"));
3952

4053
return (response);
4154
}
@@ -51,7 +64,7 @@ bool setNMEASettings()
5164
customCfg.len = 0; // Setting the len (length) to zero let's us poll the current settings
5265
customCfg.startingSpot = 0; // Always set the startingSpot to zero (unless you really know what you are doing)
5366

54-
uint16_t maxWait = 250; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)
67+
uint16_t maxWait = 1250; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)
5568

5669
// Read the current setting. The results will be loaded into customCfg.
5770
if (i2cGNSS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
@@ -84,7 +97,7 @@ bool getSBAS()
8497
customCfg.len = 0; // Setting the len (length) to zero lets us poll the current settings
8598
customCfg.startingSpot = 0; // Always set the startingSpot to zero (unless you really know what you are doing)
8699

87-
uint16_t maxWait = 250; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)
100+
uint16_t maxWait = 1250; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)
88101

89102
// Read the current setting. The results will be loaded into customCfg.
90103
if (i2cGNSS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
@@ -108,7 +121,7 @@ bool setSBAS(bool enableSBAS)
108121
customCfg.len = 0; // Setting the len (length) to zero lets us poll the current settings
109122
customCfg.startingSpot = 0; // Always set the startingSpot to zero (unless you really know what you are doing)
110123

111-
uint16_t maxWait = 250; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)
124+
uint16_t maxWait = 1250; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)
112125

113126
// Read the current setting. The results will be loaded into customCfg.
114127
if (i2cGNSS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK

Firmware/RTK_Surveyor/System.ino

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,19 @@
3131

3232
//Setup the u-blox module for any setup (base or rover)
3333
//In general we check if the setting is incorrect before writing it. Otherwise, the set commands have, on rare occasion, become
34-
//corrupt. The worst is when the I2C port gets turned off or the I2C address gets borked. We should only have to configure
35-
//a fresh u-blox module once and never again.
34+
//corrupt. The worst is when the I2C port gets turned off or the I2C address gets borked.
3635
bool configureUbloxModule()
3736
{
3837
boolean response = true;
38+
int maxWait = 2000;
39+
40+
i2cGNSS.checkUblox(); //Regularly poll to get latest data and any RTCM
41+
42+
//The first thing we do is go to 1Hz to lighten any I2C traffic from a previous configuration
43+
if (i2cGNSS.getNavigationFrequency(maxWait) != 1)
44+
response &= i2cGNSS.setNavigationFrequency(1, maxWait);
45+
if (response == false)
46+
Serial.println(F("Set rate failed"));
3947

4048
#define OUTPUT_SETTING 14
4149
#define INPUT_SETTING 12
@@ -65,6 +73,8 @@ bool configureUbloxModule()
6573
response &= i2cGNSS.setPortInput(COM_PORT_UART2, COM_TYPE_RTCM3); //Set the UART2 to input RTCM
6674
}
6775

76+
//Turn on RTCM over I2C port so that we can harvest RTCM over I2C and send out over WiFi
77+
//This is easier than parsing over UART because the library handles the frame detection
6878
getPortSettings(COM_PORT_I2C); //Load the settingPayload with this port's settings
6979
if (settingPayload[OUTPUT_SETTING] != (COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3) || settingPayload[INPUT_SETTING] != COM_TYPE_UBX)
7080
{
@@ -101,7 +111,6 @@ bool configureUbloxModule()
101111
if (response == false)
102112
{
103113
Serial.println(F("Module failed initial config."));
104-
return (false);
105114
}
106115

107116
//Based on current settings, update the logging options within the GNSS library
@@ -255,18 +264,20 @@ bool disableNMEASentences(uint8_t portType)
255264
bool enableRTCMSentences(uint8_t portType)
256265
{
257266
bool response = true;
267+
int maxWait = 1000; //When I2C traffic is large during logging, give extra time
268+
258269
if (getRTCMSettings(UBX_RTCM_1005, portType) != 1)
259-
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1005, portType, 1); //Enable message 1005 to output through UART2, message every second
270+
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1005, portType, 1, maxWait); //Enable message 1005 to output through UART2, message every second
260271
if (getRTCMSettings(UBX_RTCM_1074, portType) != 1)
261-
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1074, portType, 1);
272+
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1074, portType, 1, maxWait);
262273
if (getRTCMSettings(UBX_RTCM_1084, portType) != 1)
263-
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1084, portType, 1);
274+
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1084, portType, 1, maxWait);
264275
if (getRTCMSettings(UBX_RTCM_1094, portType) != 1)
265-
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1094, portType, 1);
276+
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1094, portType, 1, maxWait);
266277
if (getRTCMSettings(UBX_RTCM_1124, portType) != 1)
267-
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1124, portType, 1);
278+
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1124, portType, 1, maxWait);
268279
if (getRTCMSettings(UBX_RTCM_1230, portType) != 10)
269-
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1230, portType, 10); //Enable message every 10 seconds
280+
response &= i2cGNSS.enableRTCMmessage(UBX_RTCM_1230, portType, 10, maxWait); //Enable message every 10 seconds
270281

271282
return (response);
272283
}
@@ -275,18 +286,20 @@ bool enableRTCMSentences(uint8_t portType)
275286
bool disableRTCMSentences(uint8_t portType)
276287
{
277288
bool response = true;
289+
int maxWait = 1000; //When I2C traffic is large during logging, give extra time
290+
278291
if (getRTCMSettings(UBX_RTCM_1005, portType) != 0)
279-
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1005, portType);
292+
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1005, portType, maxWait);
280293
if (getRTCMSettings(UBX_RTCM_1074, portType) != 0)
281-
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1074, portType);
294+
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1074, portType, maxWait);
282295
if (getRTCMSettings(UBX_RTCM_1084, portType) != 0)
283-
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1084, portType);
296+
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1084, portType, maxWait);
284297
if (getRTCMSettings(UBX_RTCM_1094, portType) != 0)
285-
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1094, portType);
298+
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1094, portType, maxWait);
286299
if (getRTCMSettings(UBX_RTCM_1124, portType) != 0)
287-
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1124, portType);
300+
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1124, portType, maxWait);
288301
if (getRTCMSettings(UBX_RTCM_1230, portType) != 0)
289-
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1230, portType);
302+
response &= i2cGNSS.disableRTCMmessage(UBX_RTCM_1230, portType, maxWait);
290303
return (response);
291304
}
292305

@@ -349,7 +362,7 @@ uint8_t getRTCMSettings(uint8_t msgID, uint8_t portID)
349362
customCfg.len = 2;
350363
customCfg.startingSpot = 0; // Always set the startingSpot to zero (unless you really know what you are doing)
351364

352-
uint16_t maxWait = 250; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)
365+
uint16_t maxWait = 1250; // Wait for up to 1250ms (Serial may need a lot longer e.g. 1100)
353366

354367
settingPayload[0] = UBX_RTCM_MSB;
355368
settingPayload[1] = msgID;

0 commit comments

Comments
 (0)