@@ -102,7 +102,7 @@ bool UM980::isConnected()
102102{
103103 for (int x = 0 ; x < 3 ; x++)
104104 {
105- serialPrintln ( " UNLOG " ); // Blindly tell unit to stop transmitting
105+ disableOutput ( ); // Tell unit to stop transmitting
106106
107107 // Wait until serial stops coming in
108108 uint16_t maxTime = 500 ;
@@ -511,18 +511,44 @@ bool UM980::setRTCMMessage(const char *sentenceType, float outputRate)
511511// Warning, each message has to be individually re-enabled
512512bool UM980::disableOutput ()
513513{
514+ stopAutoReports (); // Remove pointers so we will re-init next check
515+
514516 return (sendCommand (" UNLOG" ));
515517}
516518
517519// Disable all messages on a given port
518520bool UM980::disableOutputPort (const char *comName)
519521{
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+
520525 char command[50 ];
521526 snprintf (command, sizeof (command), " UNLOG %s" , comName);
522527
523528 return (sendCommand (command));
524529}
525530
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+
526552// Clear saved configurations, satellite ephemerides, position information, and reset baud rate to 115200bps.
527553bool UM980::factoryReset ()
528554{
@@ -789,7 +815,7 @@ void UM980::unicoreHandler(uint8_t *response, uint16_t length)
789815
790816 if (messageID == messageIdBestnav)
791817 {
792- // debugPrintf("BestNav Handler");
818+ debugPrintf (" BestNav Handler" );
793819 CHECK_POINTER_VOID (packetBESTNAV, initBestnav); // Check that RAM has been allocated
794820
795821 lastUpdateGeodetic = millis (); // Update stale marker
@@ -829,7 +855,7 @@ void UM980::unicoreHandler(uint8_t *response, uint16_t length)
829855 }
830856 else if (messageID == messageIdRectime)
831857 {
832- // debugPrintf("RecTime Handler");
858+ debugPrintf (" RecTime Handler" );
833859 CHECK_POINTER_VOID (packetRECTIME, initRectime); // Check that RAM has been allocated
834860
835861 lastUpdateDateTime = millis ();
@@ -854,7 +880,7 @@ void UM980::unicoreHandler(uint8_t *response, uint16_t length)
854880 }
855881 else if (messageID == messageIdBestnavXyz)
856882 {
857- // debugPrintf("BestNavXyz Handler");
883+ // debugPrintf("BestNavXyz Handler");
858884 CHECK_POINTER_VOID (packetBESTNAVXYZ, initBestnavXyz); // Check that RAM has been allocated
859885
860886 lastUpdateEcef = millis (); // Update stale marker
@@ -894,9 +920,11 @@ bool UM980::initBestnav(uint8_t rate)
894920 return (false );
895921 }
896922
923+ debugPrintf (" BestNav started" );
924+
897925 // Wait until first report is available
898926 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
900928 unsigned long startTime = millis ();
901929 while (1 )
902930 {
@@ -941,7 +969,7 @@ bool UM980::initBestnavXyz(uint8_t rate)
941969
942970 // Wait until first report is available
943971 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
945973 unsigned long startTime = millis ();
946974 while (1 )
947975 {
@@ -972,6 +1000,8 @@ bool UM980::initRectime(uint8_t rate)
9721000 // packetRECTIME->callbackPointerPtr = nullptr;
9731001 // packetRECTIME->callbackData = nullptr;
9741002
1003+ debugPrintf (" RecTime started" );
1004+
9751005 // Start outputting RECTIME in Binary on this COM port
9761006 char command[50 ];
9771007 snprintf (command, sizeof (command), " RECTIMEB %d" , rate);
@@ -986,7 +1016,7 @@ bool UM980::initRectime(uint8_t rate)
9861016
9871017 // Wait until first report is available
9881018 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
9901020 unsigned long startTime = millis ();
9911021 while (1 )
9921022 {
0 commit comments