@@ -296,14 +296,8 @@ void UM980::disableDebugging()
296296bool UM980::update ()
297297{
298298 bool newData = false ;
299-
300- unicoreLibrarySemaphoreBlock = true ; // Allow external tasks to control serial hardware
301-
302299 while (serialAvailable ())
303300 newData = updateOnce ();
304-
305- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
306-
307301 return (newData);
308302}
309303
@@ -1047,7 +1041,6 @@ Um980Result UM980::sendString(const char *command, uint16_t maxWaitMs)
10471041 if (wait++ == maxWaitMs)
10481042 {
10491043 debugPrintf (" Unicore Lib: Command timeout" );
1050- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
10511044 return (UM980_RESULT_TIMEOUT_RESPONSE);
10521045 }
10531046
@@ -1062,7 +1055,6 @@ Um980Result UM980::sendString(const char *command, uint16_t maxWaitMs)
10621055 if (commandResponse == UM980_RESULT_RESPONSE_COMMAND_ERROR)
10631056 {
10641057 debugPrintf (" Unicore Lib: Command error" );
1065- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
10661058 return (UM980_RESULT_RESPONSE_COMMAND_ERROR);
10671059 }
10681060
@@ -1220,7 +1212,7 @@ void UM980::unicoreHandler(uint8_t *response, uint16_t length)
12201212 if (responsePointer != nullptr ) // Found
12211213 {
12221214 char gngga[100 ];
1223- strncpy (gngga, (const char *)response, length - 1 ); // Make copy before strtok
1215+ strncpy (gngga, (const char *)response, length); // Make copy before strtok
12241216
12251217 debugPrintf (" Unicore Lib: GNGGA message: %s\r\n " , gngga);
12261218
@@ -1270,6 +1262,8 @@ bool UM980::initVersion()
12701262
12711263 debugPrintf (" VERSION started" );
12721264
1265+ unicoreLibrarySemaphoreBlock = true ; // Prevent external tasks from harvesting serial data
1266+
12731267 // Wait until response is received
12741268 lastUpdateVersion = 0 ;
12751269 uint16_t maxWait = 1000 ; // Wait for one response to come in
@@ -1284,10 +1278,12 @@ bool UM980::initVersion()
12841278 debugPrintf (" GNSS: Failed to get response from VERSION start" );
12851279 delete packetVERSION;
12861280 packetVERSION = nullptr ;
1281+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
12871282 return (false );
12881283 }
12891284 }
12901285
1286+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
12911287 return (true );
12921288}
12931289
@@ -1321,6 +1317,8 @@ bool UM980::initBestnav(uint8_t rate)
13211317
13221318 debugPrintf (" BestNav started" );
13231319
1320+ unicoreLibrarySemaphoreBlock = true ; // Prevent external tasks from harvesting serial data
1321+
13241322 // Wait until first report is available
13251323 lastUpdateGeodetic = 0 ;
13261324 uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
@@ -1335,10 +1333,12 @@ bool UM980::initBestnav(uint8_t rate)
13351333 debugPrintf (" GNSS: Failed to get response from BestNav start" );
13361334 delete packetBESTNAV;
13371335 packetBESTNAV = nullptr ;
1336+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
13381337 return (false );
13391338 }
13401339 }
13411340
1341+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
13421342 return (true );
13431343}
13441344
@@ -1372,6 +1372,8 @@ bool UM980::initBestnavXyz(uint8_t rate)
13721372
13731373 debugPrintf (" BestNavXYZB started" );
13741374
1375+ unicoreLibrarySemaphoreBlock = true ; // Prevent external tasks from harvesting serial data
1376+
13751377 // Wait until first report is available
13761378 lastUpdateEcef = 0 ;
13771379 uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
@@ -1386,10 +1388,13 @@ bool UM980::initBestnavXyz(uint8_t rate)
13861388 debugPrintf (" GNSS: Failed to get response from BestNavXyz start" );
13871389 delete packetBESTNAVXYZ;
13881390 packetBESTNAVXYZ = nullptr ;
1391+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
13891392 return (false );
13901393 }
13911394 }
13921395
1396+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1397+
13931398 return (true );
13941399}
13951400
@@ -1425,6 +1430,8 @@ bool UM980::initRectime(uint8_t rate)
14251430
14261431 debugPrintf (" RecTimeB started" );
14271432
1433+ unicoreLibrarySemaphoreBlock = true ; // Allow external tasks to control serial hardware
1434+
14281435 // Wait until first report is available
14291436 lastUpdateDateTime = 0 ;
14301437 uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
@@ -1439,10 +1446,13 @@ bool UM980::initRectime(uint8_t rate)
14391446 debugPrintf (" GNSS: Failed to get response from RecTime start" );
14401447 delete packetRECTIME;
14411448 packetRECTIME = nullptr ;
1449+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
14421450 return (false );
14431451 }
14441452 }
14451453
1454+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1455+
14461456 return (true );
14471457}
14481458
0 commit comments