Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 53bfd1b

Browse files
committed
Change configureMessage() so it only affects the port the user passes in
1 parent b6c7cf4 commit 53bfd1b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Diff for: src/SparkFun_Ublox_Arduino_Library.cpp

+14-8
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,7 @@ uint8_t SFE_UBLOX_GPS::getNavigationFrequency(uint16_t maxWait)
21772177

21782178
//This will load the payloadCfg array with current settings of the given register
21792179
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
2180-
return (0); //If command send fails then bail
2180+
return (false); //If command send fails then bail
21812181

21822182
uint16_t measurementRate = 0;
21832183

@@ -2233,18 +2233,24 @@ boolean SFE_UBLOX_GPS::setAutoPVT(boolean enable, boolean implicitUpdate, uint16
22332233
//Configure a given message type for a given port (UART1, I2C, SPI, etc)
22342234
boolean SFE_UBLOX_GPS::configureMessage(uint8_t msgClass, uint8_t msgID, uint8_t portID, uint8_t sendRate, uint16_t maxWait)
22352235
{
2236+
//Poll for the current settings for a given message
22362237
packetCfg.cls = UBX_CLASS_CFG;
22372238
packetCfg.id = UBX_CFG_MSG;
2238-
packetCfg.len = 8;
2239+
packetCfg.len = 2;
22392240
packetCfg.startingSpot = 0;
22402241

2241-
//Clear packet payload
2242-
for (uint8_t x = 0; x < packetCfg.len; x++)
2243-
packetCfg.payload[x] = 0;
2242+
payloadCfg[0] = msgClass;
2243+
payloadCfg[1] = msgID;
22442244

2245-
packetCfg.payload[0] = msgClass;
2246-
packetCfg.payload[1] = msgID;
2247-
packetCfg.payload[2 + portID] = sendRate; //Send rate is relative to the event a message is registered on. For example, if the rate of a navigation message is set to 2, the message is sent every 2nd navigation solution.
2245+
//This will load the payloadCfg array with current settings of the given register
2246+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
2247+
return (false); //If command send fails then bail
2248+
2249+
//Now send it back with new mods
2250+
packetCfg.len = 8;
2251+
2252+
//payloadCfg is now loaded with current bytes. Change only the ones we need to
2253+
payloadCfg[2 + portID] = sendRate; //Send rate is relative to the event a message is registered on. For example, if the rate of a navigation message is set to 2, the message is sent every 2nd navigation solution.
22482254

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

0 commit comments

Comments
 (0)