@@ -102,7 +102,7 @@ bool UM980::isConnected()
102
102
{
103
103
for (int x = 0 ; x < 3 ; x++)
104
104
{
105
- serialPrintln ( " UNLOG " ); // Blindly tell unit to stop transmitting
105
+ disableOutput ( ); // Tell unit to stop transmitting
106
106
107
107
// Wait until serial stops coming in
108
108
uint16_t maxTime = 500 ;
@@ -511,18 +511,44 @@ bool UM980::setRTCMMessage(const char *sentenceType, float outputRate)
511
511
// Warning, each message has to be individually re-enabled
512
512
bool UM980::disableOutput ()
513
513
{
514
+ stopAutoReports (); // Remove pointers so we will re-init next check
515
+
514
516
return (sendCommand (" UNLOG" ));
515
517
}
516
518
517
519
// Disable all messages on a given port
518
520
bool UM980::disableOutputPort (const char *comName)
519
521
{
522
+ // We don't know if this is the COM port we are communicating on, so err on the side of caution.
523
+ stopAutoReports (); // Remove pointers so we will re-init next check
524
+
520
525
char command[50 ];
521
526
snprintf (command, sizeof (command), " UNLOG %s" , comName);
522
527
523
528
return (sendCommand (command));
524
529
}
525
530
531
+ // We've issued an unlog, so the binary messages will no longer be coming in automatically
532
+ // Turn off pointers so the next time a getLatitude() is issued, the associated messsage is reinit'd
533
+ void UM980::stopAutoReports ()
534
+ {
535
+ if (packetBESTNAV != nullptr )
536
+ {
537
+ delete packetBESTNAV;
538
+ packetBESTNAV = nullptr ;
539
+ }
540
+ if (packetBESTNAVXYZ != nullptr )
541
+ {
542
+ delete packetBESTNAVXYZ;
543
+ packetBESTNAVXYZ = nullptr ;
544
+ }
545
+ if (packetRECTIME != nullptr )
546
+ {
547
+ delete packetRECTIME;
548
+ packetRECTIME = nullptr ;
549
+ }
550
+ }
551
+
526
552
// Clear saved configurations, satellite ephemerides, position information, and reset baud rate to 115200bps.
527
553
bool UM980::factoryReset ()
528
554
{
@@ -789,7 +815,7 @@ void UM980::unicoreHandler(uint8_t *response, uint16_t length)
789
815
790
816
if (messageID == messageIdBestnav)
791
817
{
792
- // debugPrintf("BestNav Handler");
818
+ debugPrintf (" BestNav Handler" );
793
819
CHECK_POINTER_VOID (packetBESTNAV, initBestnav); // Check that RAM has been allocated
794
820
795
821
lastUpdateGeodetic = millis (); // Update stale marker
@@ -829,7 +855,7 @@ void UM980::unicoreHandler(uint8_t *response, uint16_t length)
829
855
}
830
856
else if (messageID == messageIdRectime)
831
857
{
832
- // debugPrintf("RecTime Handler");
858
+ debugPrintf (" RecTime Handler" );
833
859
CHECK_POINTER_VOID (packetRECTIME, initRectime); // Check that RAM has been allocated
834
860
835
861
lastUpdateDateTime = millis ();
@@ -854,7 +880,7 @@ void UM980::unicoreHandler(uint8_t *response, uint16_t length)
854
880
}
855
881
else if (messageID == messageIdBestnavXyz)
856
882
{
857
- // debugPrintf("BestNavXyz Handler");
883
+ // debugPrintf("BestNavXyz Handler");
858
884
CHECK_POINTER_VOID (packetBESTNAVXYZ, initBestnavXyz); // Check that RAM has been allocated
859
885
860
886
lastUpdateEcef = millis (); // Update stale marker
@@ -894,9 +920,11 @@ bool UM980::initBestnav(uint8_t rate)
894
920
return (false );
895
921
}
896
922
923
+ debugPrintf (" BestNav started" );
924
+
897
925
// Wait until first report is available
898
926
lastUpdateGeodetic = 0 ;
899
- uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
927
+ uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
900
928
unsigned long startTime = millis ();
901
929
while (1 )
902
930
{
@@ -941,7 +969,7 @@ bool UM980::initBestnavXyz(uint8_t rate)
941
969
942
970
// Wait until first report is available
943
971
lastUpdateEcef = 0 ;
944
- uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
972
+ uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
945
973
unsigned long startTime = millis ();
946
974
while (1 )
947
975
{
@@ -972,6 +1000,8 @@ bool UM980::initRectime(uint8_t rate)
972
1000
// packetRECTIME->callbackPointerPtr = nullptr;
973
1001
// packetRECTIME->callbackData = nullptr;
974
1002
1003
+ debugPrintf (" RecTime started" );
1004
+
975
1005
// Start outputting RECTIME in Binary on this COM port
976
1006
char command[50 ];
977
1007
snprintf (command, sizeof (command), " RECTIMEB %d" , rate);
@@ -986,7 +1016,7 @@ bool UM980::initRectime(uint8_t rate)
986
1016
987
1017
// Wait until first report is available
988
1018
lastUpdateDateTime = 0 ;
989
- uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
1019
+ uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
990
1020
unsigned long startTime = millis ();
991
1021
while (1 )
992
1022
{
0 commit comments