Skip to content

Commit 068f6f1

Browse files
authored
Merge pull request #73 from sparkfun/release_candidate
v2.0.16
2 parents 63194e7 + 16351b6 commit 068f6f1

File tree

8 files changed

+259
-41
lines changed

8 files changed

+259
-41
lines changed

Diff for: Utils/UBX_Integrity_Checker.py

+58-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Checks the integrity of u-blox binary files
22

33
# Written by: Paul Clark
4-
# Last update: August 26th 2020
4+
# Last update: October 17th 2021
55

66
# Reads a UBX file and checks the integrity of both UBX and NMEA data
77
# Will rewind and re-sync if an error is found
8+
# Will create a repaired file if desired
89

910
# SparkFun code, firmware, and software is released under the MIT License (http://opensource.org/licenses/MIT)
1011
#
@@ -70,6 +71,17 @@ def csum(byte, sum1, sum2):
7071
else:
7172
containsNMEA = False
7273

74+
# Ask user if the file should be repaired
75+
response = input('Do you want to repair the file? (y/N): ') # Get the response
76+
if (response == '') or (response == 'N') or (response == 'n'):
77+
repairFile = False
78+
else:
79+
repairFile = True
80+
if (filename[-4] == '.'):
81+
repairFilename = filename[:-4] + '.repair' + filename[-4:]
82+
else:
83+
repairFilename = filename + '.repair'
84+
7385
print()
7486
print('Processing',filename)
7587
print()
@@ -81,7 +93,14 @@ def csum(byte, sum1, sum2):
8193
except:
8294
raise Exception('Invalid file!')
8395

84-
processed = -1 # The nunber of bytes processed
96+
# Try to open repair file for writing
97+
if (repairFile):
98+
try:
99+
fo = open(repairFilename,"wb")
100+
except:
101+
raise Exception('Could not open repair file!')
102+
103+
processed = -1 # The number of bytes processed
85104
messages = {} # The collected message types
86105
longest = 0 # The length of the longest UBX message
87106
keepGoing = True
@@ -137,6 +156,9 @@ def csum(byte, sum1, sum2):
137156
resync_in_progress = False # Flag to indicate if a resync is in progress
138157
message_start_byte = 0 # Record where the latest message started (for resync reporting)
139158

159+
rewind_repair_file_to = 0 # Keep a note of where to rewind the repair file to if sync is lost
160+
repaired_file_bytes = 0 # Keep a note of how many bytes have been written to the repair file
161+
140162
try:
141163
while keepGoing:
142164

@@ -149,6 +171,11 @@ def csum(byte, sum1, sum2):
149171

150172
processed = processed + 1 # Keep a record of how many bytes have been read and processed
151173

174+
# Write the byte to the repair file if desired
175+
if (repairFile):
176+
fo.write(fileBytes)
177+
repaired_file_bytes = repaired_file_bytes + 1
178+
152179
# Process data bytes according to ubx_nmea_state
153180
# For UBX messages:
154181
# Sync Char 1: 0xB5
@@ -267,6 +294,18 @@ def csum(byte, sum1, sum2):
267294
resyncs += 1 # Increment the number of successful resyncs
268295
print("Sync successfully re-established at byte "+str(processed)+". The UBX message started at byte "+str(message_start_byte))
269296
print()
297+
if (repairFile):
298+
fo.seek(rewind_repair_file_to) # Rewind the repaired file
299+
repaired_file_bytes = rewind_repair_file_to
300+
fi.seek(message_start_byte) # Copy the valid message into the repair file
301+
repaired_bytes_to_write = processed - message_start_byte
302+
fileBytes = fi.read(repaired_bytes_to_write)
303+
fo.write(fileBytes)
304+
repaired_file_bytes = repaired_file_bytes + repaired_bytes_to_write
305+
else:
306+
if (repairFile):
307+
rewind_repair_file_to = repaired_file_bytes # Rewind repair file to here if sync is lost
308+
270309
# NMEA messages
271310
elif (ubx_nmea_state == looking_for_asterix):
272311
nmea_length = nmea_length + 1 # Increase the message length count
@@ -359,6 +398,17 @@ def csum(byte, sum1, sum2):
359398
resyncs += 1 # Increment the number of successful resyncs
360399
print("Sync successfully re-established at byte "+str(processed)+". The NMEA message started at byte "+str(message_start_byte))
361400
print()
401+
if (repairFile):
402+
fo.seek(rewind_repair_file_to) # Rewind the repaired file
403+
repaired_file_bytes = rewind_repair_file_to
404+
fi.seek(message_start_byte) # Copy the valid message into the repair file
405+
repaired_bytes_to_write = processed - message_start_byte
406+
fileBytes = fi.read(repaired_bytes_to_write)
407+
fo.write(fileBytes)
408+
repaired_file_bytes = repaired_file_bytes + repaired_bytes_to_write
409+
else:
410+
if (repairFile):
411+
rewind_repair_file_to = repaired_file_bytes # Rewind repair file to here if sync is lost
362412

363413
# Check if the end of the file has been reached
364414
if (processed >= filesize - 1): keepGoing = False
@@ -381,6 +431,9 @@ def csum(byte, sum1, sum2):
381431
finally:
382432
fi.close() # Close the file
383433

434+
if (repairFile):
435+
fo.close()
436+
384437
# Print the file statistics
385438
print()
386439
processed += 1
@@ -396,4 +449,7 @@ def csum(byte, sum1, sum2):
396449
if (resyncs > 0):
397450
print('Number of successful resyncs:',resyncs)
398451
print()
452+
if (repairFile):
453+
print('Repaired data written to:', repairFilename)
454+
print()
399455
print('Bye!')

Diff for: examples/Data_Logging/DataLoggingExample1_NAV_PVT/DataLoggingExample1_NAV_PVT.ino

+34-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Configuring the GNSS to automatically send NAV PVT reports over I2C and log them to file on SD card
33
By: Paul Clark
44
SparkFun Electronics
5-
Date: December 30th, 2020
5+
Date: October 18th, 2021
66
License: MIT. See license file for more information but you can
77
basically do whatever you want with this code.
88
@@ -22,8 +22,10 @@
2222
Insert a formatted micro-SD card into the socket on the Carrier Board.
2323
Connect the Carrier Board to your computer using a USB-C cable.
2424
Ensure you have the SparkFun Apollo3 boards installed: http://boardsmanager/All#SparkFun_Apollo3
25-
This code has been tested using version 1.2.1 of the Apollo3 boards on Arduino IDE 1.8.13.
26-
Select "SparkFun Artemis MicroMod" as the board type.
25+
This code has been tested using version 2.1.0 of the Apollo3 boards on Arduino IDE 1.8.13.
26+
- Version 2.1.1 of Apollo3 contains a feature which makes I2C communication with u-blox modules problematic
27+
- We recommend using v2.1.0 of Apollo3 until v2.2.0 is released
28+
Select "Artemis MicroMod Processor" as the board type.
2729
Press upload to upload the code onto the Artemis.
2830
Open the Serial Monitor at 115200 baud to see the output.
2931
@@ -51,7 +53,20 @@ SFE_UBLOX_GNSS myGNSS;
5153

5254
File myFile; //File that all GNSS data is written to
5355

54-
#define sdChipSelect CS //Primary SPI Chip Select is CS for the MicroMod Artemis Processor. Adjust for your processor if necessary.
56+
//Define the microSD (SPI) Chip Select pin. Adjust for your processor if necessary.
57+
#if defined(ARDUINO_ARCH_APOLLO3) // Check for SparkFun Apollo3 (Artemis) v1 or v2
58+
#if defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB) // Check for the Artemis MicroMod Processor Board on Apollo3 v2
59+
#define sdChipSelect SPI_CS // SPI (microSD) Chip Select for the Artemis MicroMod Processor Board on Apollo3 v2
60+
#elif defined(ARDUINO_AM_AP3_SFE_ARTEMIS_MICROMOD) // Check for the Artemis MicroMod Processor Board on Apollo3 v1
61+
#define sdChipSelect CS // SPI (microSD) Chip Select for the Artemis MicroMod Processor Board on Apollo3 v1
62+
#else
63+
#define sdChipSelect CS // Catch-all for the other Artemis Boards - change this if required to match your hardware
64+
#endif
65+
#else
66+
67+
#define sdChipSelect CS // Catch-all for all non-Artemis boards - change this if required to match your hardware
68+
69+
#endif
5570

5671
#define packetLength 100 // NAV PVT is 92 + 8 bytes in length (including the sync chars, class, id, length and checksum bytes)
5772

@@ -107,8 +122,20 @@ void setup()
107122

108123
Wire.begin(); // Start I2C communication with the GNSS
109124

110-
#if defined(AM_PART_APOLLO3)
111-
Wire.setPullups(0); // On the Artemis, we can disable the internal I2C pull-ups too to help reduce bus errors
125+
// On the Artemis, we can disable the internal I2C pull-ups too to help reduce bus errors
126+
#if defined(AM_PART_APOLLO3) // Check for SparkFun Apollo3 (Artemis) v1
127+
Wire.setPullups(0); // Disable the internal I2C pull-ups on Apollo3 v1
128+
#elif defined(ARDUINO_ARCH_APOLLO3) // Else check for SparkFun Apollo3 (Artemis) (v2)
129+
#if defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB) // Check for the Artemis MicroMod Processor Board on Apollo3 v2
130+
// On Apollo3 v2 we can still disable the pull-ups but we need to do it manually
131+
// The IOM and pin numbers here are specific to the Artemis MicroMod Processor Board
132+
am_hal_gpio_pincfg_t sclPinCfg = g_AM_BSP_GPIO_IOM4_SCL; // Artemis MicroMod Processor Board uses IOM4 for I2C communication
133+
am_hal_gpio_pincfg_t sdaPinCfg = g_AM_BSP_GPIO_IOM4_SDA;
134+
sclPinCfg.ePullup = AM_HAL_GPIO_PIN_PULLUP_NONE; // Disable the pull-ups
135+
sdaPinCfg.ePullup = AM_HAL_GPIO_PIN_PULLUP_NONE;
136+
pin_config(PinName(39), sclPinCfg); // Artemis MicroMod Processor Board uses Pin/Pad 39 for SCL
137+
pin_config(PinName(40), sdaPinCfg); // Artemis MicroMod Processor Board uses Pin/Pad 40 for SDA
138+
#endif
112139
#endif
113140

114141
while (Serial.available()) // Make sure the Serial buffer is empty
@@ -199,7 +226,7 @@ void loop()
199226
if (Serial.available()) // Check if the user wants to stop logging
200227
{
201228
myFile.close(); // Close the data file
202-
Serial.println(F("Logging stopped. Freezing..."));
229+
Serial.println(F("\r\nLogging stopped. Freezing..."));
203230
while(1); // Do nothing more
204231
}
205232

Diff for: examples/Data_Logging/DataLoggingExample2_TIM_TM2/DataLoggingExample2_TIM_TM2.ino

+34-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Configuring the GNSS to automatically send TIM TM2 reports over I2C and log them to file on SD card
33
By: Paul Clark
44
SparkFun Electronics
5-
Date: December 30th, 2020
5+
Date: October 18th, 2021
66
License: MIT. See license file for more information but you can
77
basically do whatever you want with this code.
88
@@ -22,8 +22,10 @@
2222
Insert a formatted micro-SD card into the socket on the Carrier Board.
2323
Connect the Carrier Board to your computer using a USB-C cable.
2424
Ensure you have the SparkFun Apollo3 boards installed: http://boardsmanager/All#SparkFun_Apollo3
25-
This code has been tested using version 1.2.1 of the Apollo3 boards on Arduino IDE 1.8.13.
26-
Select "SparkFun Artemis MicroMod" as the board type.
25+
This code has been tested using version 2.1.0 of the Apollo3 boards on Arduino IDE 1.8.13.
26+
- Version 2.1.1 of Apollo3 contains a feature which makes I2C communication with u-blox modules problematic
27+
- We recommend using v2.1.0 of Apollo3 until v2.2.0 is released
28+
Select "Artemis MicroMod Processor" as the board type.
2729
Press upload to upload the code onto the Artemis.
2830
Open the Serial Monitor at 115200 baud to see the output.
2931
@@ -64,7 +66,20 @@ SFE_UBLOX_GNSS myGNSS;
6466

6567
File myFile; //File that all GNSS data is written to
6668

67-
#define sdChipSelect CS //Primary SPI Chip Select is CS for the MicroMod Artemis Processor. Adjust for your processor if necessary.
69+
//Define the microSD (SPI) Chip Select pin. Adjust for your processor if necessary.
70+
#if defined(ARDUINO_ARCH_APOLLO3) // Check for SparkFun Apollo3 (Artemis) v1 or v2
71+
#if defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB) // Check for the Artemis MicroMod Processor Board on Apollo3 v2
72+
#define sdChipSelect SPI_CS // SPI (microSD) Chip Select for the Artemis MicroMod Processor Board on Apollo3 v2
73+
#elif defined(ARDUINO_AM_AP3_SFE_ARTEMIS_MICROMOD) // Check for the Artemis MicroMod Processor Board on Apollo3 v1
74+
#define sdChipSelect CS // SPI (microSD) Chip Select for the Artemis MicroMod Processor Board on Apollo3 v1
75+
#else
76+
#define sdChipSelect CS // Catch-all for the other Artemis Boards - change this if required to match your hardware
77+
#endif
78+
#else
79+
80+
#define sdChipSelect CS // Catch-all for all non-Artemis boards - change this if required to match your hardware
81+
82+
#endif
6883

6984
#define packetLength 36 // TIM TM2 is 28 + 8 bytes in length (including the sync chars, class, id, length and checksum bytes)
7085

@@ -113,8 +128,20 @@ void setup()
113128

114129
Wire.begin(); // Start I2C communication with the GNSS
115130

116-
#if defined(AM_PART_APOLLO3)
117-
Wire.setPullups(0); // On the Artemis, we can disable the internal I2C pull-ups too to help reduce bus errors
131+
// On the Artemis, we can disable the internal I2C pull-ups too to help reduce bus errors
132+
#if defined(AM_PART_APOLLO3) // Check for SparkFun Apollo3 (Artemis) v1
133+
Wire.setPullups(0); // Disable the internal I2C pull-ups on Apollo3 v1
134+
#elif defined(ARDUINO_ARCH_APOLLO3) // Else check for SparkFun Apollo3 (Artemis) (v2)
135+
#if defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB) // Check for the Artemis MicroMod Processor Board on Apollo3 v2
136+
// On Apollo3 v2 we can still disable the pull-ups but we need to do it manually
137+
// The IOM and pin numbers here are specific to the Artemis MicroMod Processor Board
138+
am_hal_gpio_pincfg_t sclPinCfg = g_AM_BSP_GPIO_IOM4_SCL; // Artemis MicroMod Processor Board uses IOM4 for I2C communication
139+
am_hal_gpio_pincfg_t sdaPinCfg = g_AM_BSP_GPIO_IOM4_SDA;
140+
sclPinCfg.ePullup = AM_HAL_GPIO_PIN_PULLUP_NONE; // Disable the pull-ups
141+
sdaPinCfg.ePullup = AM_HAL_GPIO_PIN_PULLUP_NONE;
142+
pin_config(PinName(39), sclPinCfg); // Artemis MicroMod Processor Board uses Pin/Pad 39 for SCL
143+
pin_config(PinName(40), sdaPinCfg); // Artemis MicroMod Processor Board uses Pin/Pad 40 for SDA
144+
#endif
118145
#endif
119146

120147
while (Serial.available()) // Make sure the Serial buffer is empty
@@ -205,7 +232,7 @@ void loop()
205232
if (Serial.available()) // Check if the user wants to stop logging
206233
{
207234
myFile.close(); // Close the data file
208-
Serial.println(F("Logging stopped. Freezing..."));
235+
Serial.println(F("\r\nLogging stopped. Freezing..."));
209236
while(1); // Do nothing more
210237
}
211238

Diff for: examples/Data_Logging/DataLoggingExample3_RXM_SFRBX_and_RAWX/DataLoggingExample3_RXM_SFRBX_and_RAWX.ino

+33-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Configuring the GNSS to automatically send RXM SFRBX and RAWX reports over I2C and log them to file on SD card
33
By: Paul Clark
44
SparkFun Electronics
5-
Date: December 30th, 2020
5+
Date: October 18th, 2021
66
License: MIT. See license file for more information but you can
77
basically do whatever you want with this code.
88
@@ -34,8 +34,10 @@
3434
Insert a formatted micro-SD card into the socket on the Carrier Board.
3535
Connect the Carrier Board to your computer using a USB-C cable.
3636
Ensure you have the SparkFun Apollo3 boards installed: http://boardsmanager/All#SparkFun_Apollo3
37-
This code has been tested using version 1.2.1 of the Apollo3 boards on Arduino IDE 1.8.13.
38-
Select "SparkFun Artemis MicroMod" as the board type.
37+
This code has been tested using version 2.1.0 of the Apollo3 boards on Arduino IDE 1.8.13.
38+
- Version 2.1.1 of Apollo3 contains a feature which makes I2C communication with u-blox modules problematic
39+
- We recommend using v2.1.0 of Apollo3 until v2.2.0 is released
40+
Select "Artemis MicroMod Processor" as the board type.
3941
Press upload to upload the code onto the Artemis.
4042
Open the Serial Monitor at 115200 baud to see the output.
4143
@@ -57,7 +59,20 @@ SFE_UBLOX_GNSS myGNSS;
5759

5860
File myFile; //File that all GNSS data is written to
5961

60-
#define sdChipSelect CS //Primary SPI Chip Select is CS for the MicroMod Artemis Processor. Adjust for your processor if necessary.
62+
//Define the microSD (SPI) Chip Select pin. Adjust for your processor if necessary.
63+
#if defined(ARDUINO_ARCH_APOLLO3) // Check for SparkFun Apollo3 (Artemis) v1 or v2
64+
#if defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB) // Check for the Artemis MicroMod Processor Board on Apollo3 v2
65+
#define sdChipSelect SPI_CS // SPI (microSD) Chip Select for the Artemis MicroMod Processor Board on Apollo3 v2
66+
#elif defined(ARDUINO_AM_AP3_SFE_ARTEMIS_MICROMOD) // Check for the Artemis MicroMod Processor Board on Apollo3 v1
67+
#define sdChipSelect CS // SPI (microSD) Chip Select for the Artemis MicroMod Processor Board on Apollo3 v1
68+
#else
69+
#define sdChipSelect CS // Catch-all for the other Artemis Boards - change this if required to match your hardware
70+
#endif
71+
#else
72+
73+
#define sdChipSelect CS // Catch-all for all non-Artemis boards - change this if required to match your hardware
74+
75+
#endif
6176

6277
#define sdWriteSize 512 // Write data to the SD card in blocks of 512 bytes
6378
#define fileBufferSize 16384 // Allocate 16KBytes of RAM for UBX message storage
@@ -106,8 +121,20 @@ void setup()
106121

107122
Wire.begin(); // Start I2C communication
108123

109-
#if defined(AM_PART_APOLLO3)
110-
Wire.setPullups(0); // On the Artemis, we can disable the internal I2C pull-ups too to help reduce bus errors
124+
// On the Artemis, we can disable the internal I2C pull-ups too to help reduce bus errors
125+
#if defined(AM_PART_APOLLO3) // Check for SparkFun Apollo3 (Artemis) v1
126+
Wire.setPullups(0); // Disable the internal I2C pull-ups on Apollo3 v1
127+
#elif defined(ARDUINO_ARCH_APOLLO3) // Else check for SparkFun Apollo3 (Artemis) (v2)
128+
#if defined(ARDUINO_APOLLO3_SFE_ARTEMIS_MM_PB) // Check for the Artemis MicroMod Processor Board on Apollo3 v2
129+
// On Apollo3 v2 we can still disable the pull-ups but we need to do it manually
130+
// The IOM and pin numbers here are specific to the Artemis MicroMod Processor Board
131+
am_hal_gpio_pincfg_t sclPinCfg = g_AM_BSP_GPIO_IOM4_SCL; // Artemis MicroMod Processor Board uses IOM4 for I2C communication
132+
am_hal_gpio_pincfg_t sdaPinCfg = g_AM_BSP_GPIO_IOM4_SDA;
133+
sclPinCfg.ePullup = AM_HAL_GPIO_PIN_PULLUP_NONE; // Disable the pull-ups
134+
sdaPinCfg.ePullup = AM_HAL_GPIO_PIN_PULLUP_NONE;
135+
pin_config(PinName(39), sclPinCfg); // Artemis MicroMod Processor Board uses Pin/Pad 39 for SCL
136+
pin_config(PinName(40), sdaPinCfg); // Artemis MicroMod Processor Board uses Pin/Pad 40 for SDA
137+
#endif
111138
#endif
112139

113140
while (Serial.available()) // Make sure the Serial buffer is empty

0 commit comments

Comments
 (0)