@@ -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
@@ -1137,6 +1145,7 @@ void UM980::unicoreHandler(uint8_t *response, uint16_t length)
1137
1145
memcpy (&extSolStat, &data[offsetBestnavExtSolStat], sizeof (uint8_t ));
1138
1146
packetBESTNAV->data .rtkSolution = extSolStat & 0x01 ; // 0 = unchecked, 1 = checked
1139
1147
packetBESTNAV->data .pseudorangeCorrection = (extSolStat >> 1 ) & 0b111 ; // Limit to three bits
1148
+ debugPrintf (" BestNav Handler 2" );
1140
1149
}
1141
1150
else if (messageID == messageIdRectime)
1142
1151
{
@@ -1212,7 +1221,7 @@ void UM980::unicoreHandler(uint8_t *response, uint16_t length)
1212
1221
if (responsePointer != nullptr ) // Found
1213
1222
{
1214
1223
char gngga[100 ];
1215
- strncpy (gngga, (const char *)response, length); // Make copy before strtok
1224
+ strncpy (gngga, (const char *)response, length - 1 ); // Make copy before strtok
1216
1225
1217
1226
debugPrintf (" Unicore Lib: GNGGA message: %s\r\n " , gngga);
1218
1227
@@ -1262,8 +1271,6 @@ bool UM980::initVersion()
1262
1271
1263
1272
debugPrintf (" VERSION started" );
1264
1273
1265
- unicoreLibrarySemaphoreBlock = true ; // Prevent external tasks from harvesting serial data
1266
-
1267
1274
// Wait until response is received
1268
1275
lastUpdateVersion = 0 ;
1269
1276
uint16_t maxWait = 1000 ; // Wait for one response to come in
@@ -1278,12 +1285,10 @@ bool UM980::initVersion()
1278
1285
debugPrintf (" GNSS: Failed to get response from VERSION start" );
1279
1286
delete packetVERSION;
1280
1287
packetVERSION = nullptr ;
1281
- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1282
1288
return (false );
1283
1289
}
1284
1290
}
1285
1291
1286
- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1287
1292
return (true );
1288
1293
}
1289
1294
@@ -1317,8 +1322,6 @@ bool UM980::initBestnav(uint8_t rate)
1317
1322
1318
1323
debugPrintf (" BestNav started" );
1319
1324
1320
- unicoreLibrarySemaphoreBlock = true ; // Prevent external tasks from harvesting serial data
1321
-
1322
1325
// Wait until first report is available
1323
1326
lastUpdateGeodetic = 0 ;
1324
1327
uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
@@ -1333,12 +1336,10 @@ bool UM980::initBestnav(uint8_t rate)
1333
1336
debugPrintf (" GNSS: Failed to get response from BestNav start" );
1334
1337
delete packetBESTNAV;
1335
1338
packetBESTNAV = nullptr ;
1336
- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1337
1339
return (false );
1338
1340
}
1339
1341
}
1340
1342
1341
- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1342
1343
return (true );
1343
1344
}
1344
1345
@@ -1372,8 +1373,6 @@ bool UM980::initBestnavXyz(uint8_t rate)
1372
1373
1373
1374
debugPrintf (" BestNavXYZB started" );
1374
1375
1375
- unicoreLibrarySemaphoreBlock = true ; // Prevent external tasks from harvesting serial data
1376
-
1377
1376
// Wait until first report is available
1378
1377
lastUpdateEcef = 0 ;
1379
1378
uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
@@ -1388,13 +1387,10 @@ bool UM980::initBestnavXyz(uint8_t rate)
1388
1387
debugPrintf (" GNSS: Failed to get response from BestNavXyz start" );
1389
1388
delete packetBESTNAVXYZ;
1390
1389
packetBESTNAVXYZ = nullptr ;
1391
- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1392
1390
return (false );
1393
1391
}
1394
1392
}
1395
1393
1396
- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1397
-
1398
1394
return (true );
1399
1395
}
1400
1396
@@ -1430,8 +1426,6 @@ bool UM980::initRectime(uint8_t rate)
1430
1426
1431
1427
debugPrintf (" RecTimeB started" );
1432
1428
1433
- unicoreLibrarySemaphoreBlock = true ; // Allow external tasks to control serial hardware
1434
-
1435
1429
// Wait until first report is available
1436
1430
lastUpdateDateTime = 0 ;
1437
1431
uint16_t maxWait = (1000 / rate) + 100 ; // Wait for one response to come in
@@ -1446,13 +1440,10 @@ bool UM980::initRectime(uint8_t rate)
1446
1440
debugPrintf (" GNSS: Failed to get response from RecTime start" );
1447
1441
delete packetRECTIME;
1448
1442
packetRECTIME = nullptr ;
1449
- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1450
1443
return (false );
1451
1444
}
1452
1445
}
1453
1446
1454
- unicoreLibrarySemaphoreBlock = false ; // Allow external tasks to control serial hardware
1455
-
1456
1447
return (true );
1457
1448
}
1458
1449
0 commit comments