@@ -296,14 +296,8 @@ void UM980::disableDebugging()
296
296
bool UM980::update ()
297
297
{
298
298
bool newData = false ;
299
-
300
- unicoreLibrarySemaphoreBlock = true ; // Allow external tasks to control serial hardware
301
-
302
299
while (serialAvailable ())
303
300
newData = updateOnce ();
304
-
305
- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
306
-
307
301
return (newData);
308
302
}
309
303
@@ -1047,7 +1041,6 @@ Um980Result UM980::sendString(const char *command, uint16_t maxWaitMs)
1047
1041
if (wait++ == maxWaitMs)
1048
1042
{
1049
1043
debugPrintf (" Unicore Lib: Command timeout" );
1050
- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1051
1044
return (UM980_RESULT_TIMEOUT_RESPONSE);
1052
1045
}
1053
1046
@@ -1062,7 +1055,6 @@ Um980Result UM980::sendString(const char *command, uint16_t maxWaitMs)
1062
1055
if (commandResponse == UM980_RESULT_RESPONSE_COMMAND_ERROR)
1063
1056
{
1064
1057
debugPrintf (" Unicore Lib: Command error" );
1065
- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1066
1058
return (UM980_RESULT_RESPONSE_COMMAND_ERROR);
1067
1059
}
1068
1060
@@ -1220,7 +1212,7 @@ void UM980::unicoreHandler(uint8_t *response, uint16_t length)
1220
1212
if (responsePointer != nullptr ) // Found
1221
1213
{
1222
1214
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
1224
1216
1225
1217
debugPrintf (" Unicore Lib: GNGGA message: %s\r\n " , gngga);
1226
1218
@@ -1270,6 +1262,8 @@ bool UM980::initVersion()
1270
1262
1271
1263
debugPrintf (" VERSION started" );
1272
1264
1265
+ unicoreLibrarySemaphoreBlock = true ; // Prevent external tasks from harvesting serial data
1266
+
1273
1267
// Wait until response is received
1274
1268
lastUpdateVersion = 0 ;
1275
1269
uint16_t maxWait = 1000 ; // Wait for one response to come in
@@ -1284,10 +1278,12 @@ bool UM980::initVersion()
1284
1278
debugPrintf (" GNSS: Failed to get response from VERSION start" );
1285
1279
delete packetVERSION;
1286
1280
packetVERSION = nullptr ;
1281
+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1287
1282
return (false );
1288
1283
}
1289
1284
}
1290
1285
1286
+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1291
1287
return (true );
1292
1288
}
1293
1289
@@ -1321,6 +1317,8 @@ bool UM980::initBestnav(uint8_t rate)
1321
1317
1322
1318
debugPrintf (" BestNav started" );
1323
1319
1320
+ unicoreLibrarySemaphoreBlock = true ; // Prevent external tasks from harvesting serial data
1321
+
1324
1322
// Wait until first report is available
1325
1323
lastUpdateGeodetic = 0 ;
1326
1324
uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
@@ -1335,10 +1333,12 @@ bool UM980::initBestnav(uint8_t rate)
1335
1333
debugPrintf (" GNSS: Failed to get response from BestNav start" );
1336
1334
delete packetBESTNAV;
1337
1335
packetBESTNAV = nullptr ;
1336
+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1338
1337
return (false );
1339
1338
}
1340
1339
}
1341
1340
1341
+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1342
1342
return (true );
1343
1343
}
1344
1344
@@ -1372,6 +1372,8 @@ bool UM980::initBestnavXyz(uint8_t rate)
1372
1372
1373
1373
debugPrintf (" BestNavXYZB started" );
1374
1374
1375
+ unicoreLibrarySemaphoreBlock = true ; // Prevent external tasks from harvesting serial data
1376
+
1375
1377
// Wait until first report is available
1376
1378
lastUpdateEcef = 0 ;
1377
1379
uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
@@ -1386,10 +1388,13 @@ bool UM980::initBestnavXyz(uint8_t rate)
1386
1388
debugPrintf (" GNSS: Failed to get response from BestNavXyz start" );
1387
1389
delete packetBESTNAVXYZ;
1388
1390
packetBESTNAVXYZ = nullptr ;
1391
+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1389
1392
return (false );
1390
1393
}
1391
1394
}
1392
1395
1396
+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1397
+
1393
1398
return (true );
1394
1399
}
1395
1400
@@ -1425,6 +1430,8 @@ bool UM980::initRectime(uint8_t rate)
1425
1430
1426
1431
debugPrintf (" RecTimeB started" );
1427
1432
1433
+ unicoreLibrarySemaphoreBlock = true ; // Allow external tasks to control serial hardware
1434
+
1428
1435
// Wait until first report is available
1429
1436
lastUpdateDateTime = 0 ;
1430
1437
uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
@@ -1439,10 +1446,13 @@ bool UM980::initRectime(uint8_t rate)
1439
1446
debugPrintf (" GNSS: Failed to get response from RecTime start" );
1440
1447
delete packetRECTIME;
1441
1448
packetRECTIME = nullptr ;
1449
+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1442
1450
return (false );
1443
1451
}
1444
1452
}
1445
1453
1454
+ unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1455
+
1446
1456
return (true );
1447
1457
}
1448
1458
0 commit comments