Adjust the length based on the firmware version.
The OSTC 3 dataformat does contain the profile length twice: once in the main 256 byte header, and again in the small profile header. However due to a firmware bug, both values are not identical. The value in the main header is wrong and 3 bytes larger than the value in the small profile header. This bug was fixed in firmware version 0.93. Unfortunately we rely on the length in the main header to calculate the number of bytes to read when downloading the dive. The consequence is that for all dives recorded with firmware 0.93 or later, the length is calculated incorrectly, and the download fails. Luckily the firmware version is stored in the main header too, and we can adjust the length calculation accordingly.
This commit is contained in:
parent
890f5f0b5b
commit
d7c59dff58
@ -392,8 +392,13 @@ hw_ostc3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, voi
|
||||
unsigned int idx = (latest + RB_LOGBOOK_COUNT - i) % RB_LOGBOOK_COUNT;
|
||||
unsigned int offset = idx * RB_LOGBOOK_SIZE;
|
||||
|
||||
// Get the firmware version.
|
||||
unsigned int firmware = array_uint16_be (header + offset + 0x30);
|
||||
|
||||
// Calculate the profile length.
|
||||
unsigned int length = RB_LOGBOOK_SIZE + array_uint24_le (header + offset + 9) - 6;
|
||||
if (firmware >= 93)
|
||||
length += 3;
|
||||
|
||||
// Check the fingerprint data.
|
||||
if (memcmp (header + offset + 12, device->fingerprint, sizeof (device->fingerprint)) == 0)
|
||||
@ -428,8 +433,13 @@ hw_ostc3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, voi
|
||||
unsigned int idx = (latest + RB_LOGBOOK_COUNT - i) % RB_LOGBOOK_COUNT;
|
||||
unsigned int offset = idx * RB_LOGBOOK_SIZE;
|
||||
|
||||
// Get the firmware version.
|
||||
unsigned int firmware = array_uint16_be (header + offset + 0x30);
|
||||
|
||||
// Calculate the profile length.
|
||||
unsigned int length = RB_LOGBOOK_SIZE + array_uint24_le (header + offset + 9) - 6;
|
||||
if (firmware >= 93)
|
||||
length += 3;
|
||||
|
||||
// Download the dive.
|
||||
unsigned char number[1] = {idx};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user