Skip to content

Commit 992fe16

Browse files
committed
Add blocking during Inits
1 parent 0fdd0c3 commit 992fe16

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/SparkFun_Unicore_GNSS_Arduino_Library.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,8 @@ bool UM980::initVersion()
12661266

12671267
debugPrintf("VERSION started");
12681268

1269+
unicoreLibrarySemaphoreBlock = true; // Prevent external tasks from harvesting serial data
1270+
12691271
// Wait until response is received
12701272
lastUpdateVersion = 0;
12711273
uint16_t maxWait = 1000; // Wait for one response to come in
@@ -1280,10 +1282,12 @@ bool UM980::initVersion()
12801282
debugPrintf("GNSS: Failed to get response from VERSION start");
12811283
delete packetVERSION;
12821284
packetVERSION = nullptr;
1285+
unicoreLibrarySemaphoreBlock = false; // Allow external tasks to control serial hardware
12831286
return (false);
12841287
}
12851288
}
12861289

1290+
unicoreLibrarySemaphoreBlock = false; // Allow external tasks to control serial hardware
12871291
return (true);
12881292
}
12891293

@@ -1297,10 +1301,10 @@ bool UM980::initBestnav(uint8_t rate)
12971301
}
12981302
else
12991303
{
1300-
if(startBinaryBeforeFix == true)
1304+
if (startBinaryBeforeFix == true)
13011305
Serial.println("startBinaryBeforeFix is true");
1302-
if(isNmeaFixed() == true)
1303-
Serial.println("isNmeaFixed() is true");
1306+
if (isNmeaFixed() == true)
1307+
Serial.println("isNmeaFixed() is true");
13041308
}
13051309

13061310
packetBESTNAV = new UNICORE_BESTNAV_t; // Allocate RAM for the main struct
@@ -1324,6 +1328,8 @@ bool UM980::initBestnav(uint8_t rate)
13241328

13251329
debugPrintf("BestNav started");
13261330

1331+
unicoreLibrarySemaphoreBlock = true; // Prevent external tasks from harvesting serial data
1332+
13271333
// Wait until first report is available
13281334
lastUpdateGeodetic = 0;
13291335
uint16_t maxWait = (1000 / rate) + 100; // Wait for one response to come in
@@ -1338,10 +1344,12 @@ bool UM980::initBestnav(uint8_t rate)
13381344
debugPrintf("GNSS: Failed to get response from BestNav start");
13391345
delete packetBESTNAV;
13401346
packetBESTNAV = nullptr;
1347+
unicoreLibrarySemaphoreBlock = false; // Allow external tasks to control serial hardware
13411348
return (false);
13421349
}
13431350
}
13441351

1352+
unicoreLibrarySemaphoreBlock = false; // Allow external tasks to control serial hardware
13451353
return (true);
13461354
}
13471355

@@ -1375,6 +1383,8 @@ bool UM980::initBestnavXyz(uint8_t rate)
13751383

13761384
debugPrintf("BestNavXYZB started");
13771385

1386+
unicoreLibrarySemaphoreBlock = true; // Prevent external tasks from harvesting serial data
1387+
13781388
// Wait until first report is available
13791389
lastUpdateEcef = 0;
13801390
uint16_t maxWait = (1000 / rate) + 100; // Wait for one response to come in
@@ -1389,10 +1399,13 @@ bool UM980::initBestnavXyz(uint8_t rate)
13891399
debugPrintf("GNSS: Failed to get response from BestNavXyz start");
13901400
delete packetBESTNAVXYZ;
13911401
packetBESTNAVXYZ = nullptr;
1402+
unicoreLibrarySemaphoreBlock = false; // Allow external tasks to control serial hardware
13921403
return (false);
13931404
}
13941405
}
13951406

1407+
unicoreLibrarySemaphoreBlock = false; // Allow external tasks to control serial hardware
1408+
13961409
return (true);
13971410
}
13981411

@@ -1428,6 +1441,8 @@ bool UM980::initRectime(uint8_t rate)
14281441

14291442
debugPrintf("RecTimeB started");
14301443

1444+
unicoreLibrarySemaphoreBlock = false; // Allow external tasks to control serial hardware
1445+
14311446
// Wait until first report is available
14321447
lastUpdateDateTime = 0;
14331448
uint16_t maxWait = (1000 / rate) + 100; // Wait for one response to come in
@@ -1442,10 +1457,13 @@ bool UM980::initRectime(uint8_t rate)
14421457
debugPrintf("GNSS: Failed to get response from RecTime start");
14431458
delete packetRECTIME;
14441459
packetRECTIME = nullptr;
1460+
unicoreLibrarySemaphoreBlock = false; // Allow external tasks to control serial hardware
14451461
return (false);
14461462
}
14471463
}
14481464

1465+
unicoreLibrarySemaphoreBlock = false; // Allow external tasks to control serial hardware
1466+
14491467
return (true);
14501468
}
14511469

0 commit comments

Comments
 (0)