Skip to content

Commit fbea788

Browse files
committed
Fix constellation enable/disable.
1 parent 36374f3 commit fbea788

File tree

3 files changed

+68
-11
lines changed

3 files changed

+68
-11
lines changed

Firmware/RTK_Surveyor/Rover.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ bool setNMEASettings()
100100
}
101101

102102
//Returns true if constellation is enabled
103-
bool getConstellation(uint8_t constellation)
103+
bool getConstellation(uint8_t constellationID)
104104
{
105105
uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes
106106
ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
@@ -110,7 +110,7 @@ bool getConstellation(uint8_t constellation)
110110
customCfg.len = 0; // Setting the len (length) to zero lets us poll the current settings
111111
customCfg.startingSpot = 0; // Always set the startingSpot to zero (unless you really know what you are doing)
112112

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

115115
// Read the current setting. The results will be loaded into customCfg.
116116
if (i2cGNSS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
@@ -119,7 +119,7 @@ bool getConstellation(uint8_t constellation)
119119
return (false);
120120
}
121121

122-
if (customPayload[8 + 8 * constellation] & (1 << 0)) return true; //Check if bit 0 is set
122+
if (customPayload[locateGNSSID(customPayload, constellationID) + 4] & (1 << 0)) return true; //Check if enable bit is set
123123
return false;
124124
}
125125

@@ -214,7 +214,7 @@ bool setConstellation(uint8_t constellation, bool enable)
214214
//so QZSS and GLONAS are offset by -8 bytes.
215215
uint8_t locateGNSSID(uint8_t *customPayload, uint8_t constellation)
216216
{
217-
for (int x = 0 ; x < 7 ; x++) //Assume max of 7 constellations
217+
for (int x = 0 ; x < MAX_CONSTELLATIONS ; x++)
218218
{
219219
if (customPayload[4 + 8 * x] == constellation) //Test gnssid
220220
return (4 + x * 8);

Firmware/RTK_Surveyor/menuGNSS.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,15 @@ void menuConstellations()
162162

163163
if (incoming >= 1 && incoming <= MAX_CONSTELLATIONS)
164164
{
165-
ubxConstellations[incoming - 1].enabled ^= 1;
165+
incoming--; //Align choice to constallation array of 0 to 5
166+
167+
ubxConstellations[incoming].enabled ^= 1;
166168

167169
//3.10.6: To avoid cross-correlation issues, it is recommended that GPS and QZSS are always both enabled or both disabled.
168-
if ((incoming - 1) == SFE_UBLOX_GNSS_ID_GPS || (incoming - 1) == SFE_UBLOX_GNSS_ID_QZSS)
170+
if (incoming == SFE_UBLOX_GNSS_ID_GPS || incoming == 4) //QZSS ID is 5 but array location is 4
169171
{
170-
ubxConstellations[SFE_UBLOX_GNSS_ID_GPS].enabled = ubxConstellations[incoming - 1].enabled;
171-
ubxConstellations[SFE_UBLOX_GNSS_ID_QZSS].enabled = ubxConstellations[incoming - 1].enabled;
172+
ubxConstellations[SFE_UBLOX_GNSS_ID_GPS].enabled = ubxConstellations[incoming].enabled; //GPS ID is 0 and array location is 0
173+
ubxConstellations[4].enabled = ubxConstellations[incoming].enabled; //QZSS ID is 5 but array location is 4
172174
}
173175
}
174176
else if (incoming == STATUS_PRESSED_X)

Firmware/Test Sketches/SetConstellations/SetConstellations.ino

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
05 00 04 00 01 00 11 11
3131
06 08 0C 00 00 00 11 11
3232
00 00 00 00 00 00 00 00
33-
Above, on ZED-F9P v1.12, BeiDou is disabled. Why is SBAS not being reported?
34-
Ah, it's a v1.12 bug. Works fine in v1.13 and on ZED-F9R v1.0
33+
Above, on ZED-F9P v1.12, BeiDou is disabled. Why is SBAS not being reported?
34+
Ah, it's a v1.12 bug. Works fine in v1.13 and on ZED-F9R v1.0
3535
3636
Ugh. The issue is that the doc says IMES is gnssid 4 but really QZSS is in 4th position but with ID 5.
3737
@@ -63,7 +63,7 @@ void setup()
6363

6464
Wire.begin();
6565
Wire.setClock(400000);
66-
66+
6767
//i2cGNSS.enableDebugging(); // Uncomment this line to enable debug messages
6868

6969
if (i2cGNSS.begin() == false) //Connect to the Ublox module using Wire port
@@ -164,10 +164,41 @@ void loop()
164164
else
165165
Serial.println("Disable QZSS Success");
166166
}
167+
else if(incoming == '!')
168+
{
169+
for(int x = 0 ; x < 6 ; x++)
170+
{
171+
bool isEnabled = false;
172+
if(x == 0) isEnabled = getConstellation(SFE_UBLOX_GNSS_ID_GPS);
173+
else if(x == 1) isEnabled = getConstellation(SFE_UBLOX_GNSS_ID_SBAS);
174+
else if(x == 2) isEnabled = getConstellation(SFE_UBLOX_GNSS_ID_GALILEO);
175+
else if(x == 3) isEnabled = getConstellation(SFE_UBLOX_GNSS_ID_BEIDOU);
176+
else if(x == 4) isEnabled = getConstellation(SFE_UBLOX_GNSS_ID_QZSS);
177+
else if(x == 5) isEnabled = getConstellation(SFE_UBLOX_GNSS_ID_GLONASS);
178+
179+
Serial.print("Module reports ");
180+
if(x == 0) Serial.print("GPS");
181+
else if(x == 1) Serial.print("SBAS");
182+
else if(x == 2) Serial.print("GALILEO");
183+
else if(x == 3) Serial.print("BeiDou");
184+
else if(x == 4) Serial.print("QZSS");
185+
else if(x == 5) Serial.print("GLONASS");
186+
Serial.print(": ");
187+
if (isEnabled == true)
188+
Serial.println("Enabled");
189+
else
190+
Serial.println("Disabled");
191+
}
192+
}
193+
else if(incoming == '\n' || incoming == '\r')
194+
{
195+
//Do nothing
196+
}
167197
else
168198
{
169199
//Serial.println("Unknown");
170200
}
201+
171202
}
172203

173204
}
@@ -293,3 +324,27 @@ uint8_t locateGNSSID(uint8_t *customPayload, uint8_t constellation)
293324
Serial.println(F("locateGNSSID failed"));
294325
return (0);
295326
}
327+
328+
//Returns true if constellation is enabled
329+
bool getConstellation(uint8_t constellationID)
330+
{
331+
uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes
332+
ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
333+
334+
customCfg.cls = UBX_CLASS_CFG; // This is the message Class
335+
customCfg.id = UBX_CFG_GNSS; // This is the message ID
336+
customCfg.len = 0; // Setting the len (length) to zero lets us poll the current settings
337+
customCfg.startingSpot = 0; // Always set the startingSpot to zero (unless you really know what you are doing)
338+
339+
uint16_t maxWait = 1250; // Wait for up to 250ms (Serial may need a lot longer e.g. 1100)
340+
341+
// Read the current setting. The results will be loaded into customCfg.
342+
if (i2cGNSS.sendCommand(&customCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
343+
{
344+
Serial.println(F("Get Constellation failed"));
345+
return (false);
346+
}
347+
348+
if (customPayload[locateGNSSID(customPayload, constellationID) + 4] & (1 << 0)) return true; //Check if bit 0 is set
349+
return false;
350+
}

0 commit comments

Comments
 (0)