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