@@ -197,7 +197,11 @@ void SFE_UBLOX_GPS::process(uint8_t incoming)
197
197
else if (ubxFrameClass == CLASS_NOT_AN_ACK)
198
198
processUBX (incoming, &packetCfg);
199
199
else
200
- ; // Serial.println("No frame class set");
200
+ {
201
+ #ifdef DEBUG
202
+ debug.println (F (" No frame class set" ));
203
+ #endif
204
+ }
201
205
}
202
206
else if (currentSentence == NMEA)
203
207
{
@@ -318,16 +322,20 @@ void SFE_UBLOX_GPS::processUBX(uint8_t incoming, ubxPacket *incomingUBX)
318
322
319
323
if (incomingUBX->checksumA == tempA && incomingUBX->checksumB == tempB)
320
324
{
321
- // Serial.print("Frame cleared: ");
322
- // printFrame(incomingUBX);
325
+ #ifdef DEBUG
326
+ debug.print (" Frame cleared: " );
327
+ // printFrame(incomingUBX);
328
+ #endif
323
329
324
330
incomingUBX->valid = true ;
325
331
processUBXpacket (incomingUBX); // We've got a valid packet, now do something with it
326
332
}
327
333
}
328
- else // Load this byte into the appropriate array
334
+ else // Load this byte into the payload array
329
335
{
330
- incomingUBX->payload [incomingUBX->counter - 4 ] = incoming; // Store this byte into payload array
336
+ // Check to see if we have room for this byte
337
+ if ( (incomingUBX->counter - 4 ) < MAX_PAYLOAD_SIZE)
338
+ incomingUBX->payload [incomingUBX->counter - 4 ] = incoming; // Store this byte into payload array
331
339
}
332
340
333
341
incomingUBX->counter ++;
@@ -344,7 +352,10 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
344
352
if (msg->payload [0 ] == packetCfg.cls && msg->payload [1 ] == packetCfg.id )
345
353
{
346
354
// The ack we just received matched the CLS/ID of last packetCfg sent
347
- // Serial.println("Command sent/ack'd successfully");
355
+ #ifdef DEBUG
356
+ debug.println (" Command sent/ack'd successfully" );
357
+ #endif
358
+
348
359
commandAck = true ;
349
360
}
350
361
}
@@ -474,8 +485,12 @@ boolean SFE_UBLOX_GPS::waitForResponse(uint16_t maxTime)
474
485
if (commandAck == true ) return (true );
475
486
if (packetCfg.valid == true ) return (true );
476
487
}
477
- // Serial.println("waitForResponse timeout");
478
- return (false );
488
+
489
+ #ifdef DEBUG
490
+ debug.println (F (" waitForResponse timeout" ));
491
+ #endif
492
+
493
+ return (false );
479
494
}
480
495
481
496
// Get the current TimeMode3 settings - these contain survey in statuses
@@ -735,4 +750,22 @@ int32_t SFE_UBLOX_GPS::getAltitude(uint16_t maxWait)
735
750
alt |= payloadCfg[19 ] << 8 *3 ;
736
751
737
752
return (alt);
738
- }
753
+ }
754
+
755
+ // Get the current protocol version of the Ublox module we're communicating with
756
+ // This is helpful when deiciding if we should call the high-precision Lat/Long (HPPOSLLH) or the regular (POSLLH)
757
+ uint8_t SFE_UBLOX_GPS::getProtocolVersionHigh (uint16_t maxWait)
758
+ {
759
+ // Send packet with only CLS and ID, length of zero. This will cause the module to respond with the contents of that CLS/ID.
760
+ packetCfg.cls = UBX_CLASS_MON;
761
+ packetCfg.id = UBX_MON_VER;
762
+ packetCfg.len = 0 ;
763
+
764
+ if (sendCommand (packetCfg, maxWait) == false )
765
+ return (0 ); // If command send fails then bail
766
+
767
+ // We got a response, now find the extension that contains 'PROTVER'
768
+ // The response for this register can be quite large, many hundreds of bytes so we have to use a new, much larger array
769
+
770
+ return (0 );
771
+ }
0 commit comments