Shearwater: skip deleted dives
Without this change a deleted dive on device is treated like the end of the dive list. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
a9c582e26f
commit
ec0029c4ce
@ -275,11 +275,17 @@ shearwater_petrel_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
|
|||||||
unsigned int size = dc_buffer_get_size (buffer);
|
unsigned int size = dc_buffer_get_size (buffer);
|
||||||
|
|
||||||
// Process the records in the manifest.
|
// Process the records in the manifest.
|
||||||
unsigned int count = 0;
|
unsigned int count = 0, deleted = 0;
|
||||||
unsigned int offset = 0;
|
unsigned int offset = 0;
|
||||||
while (offset < size) {
|
while (offset < size) {
|
||||||
// Check for a valid dive header.
|
// Check for a valid dive header.
|
||||||
unsigned int header = array_uint16_be (data + offset);
|
unsigned int header = array_uint16_be (data + offset);
|
||||||
|
if (header == 0x5A23) {
|
||||||
|
// this is a deleted dive; keep looking
|
||||||
|
offset += RECORD_SIZE;
|
||||||
|
deleted++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (header != 0xA5C4)
|
if (header != 0xA5C4)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -293,7 +299,7 @@ shearwater_petrel_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
|
|||||||
|
|
||||||
// Update the progress state.
|
// Update the progress state.
|
||||||
current += 1;
|
current += 1;
|
||||||
maximum -= RECORD_COUNT - count;
|
maximum -= RECORD_COUNT - count - deleted;
|
||||||
|
|
||||||
// Append the manifest records to the main buffer.
|
// Append the manifest records to the main buffer.
|
||||||
if (!dc_buffer_append (manifests, data, count * RECORD_SIZE)) {
|
if (!dc_buffer_append (manifests, data, count * RECORD_SIZE)) {
|
||||||
@ -304,7 +310,7 @@ shearwater_petrel_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop downloading manifest if there are no more records.
|
// Stop downloading manifest if there are no more records.
|
||||||
if (count != RECORD_COUNT)
|
if (count + deleted != RECORD_COUNT)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,6 +325,11 @@ shearwater_petrel_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
|
|||||||
|
|
||||||
unsigned int offset = 0;
|
unsigned int offset = 0;
|
||||||
while (offset < size) {
|
while (offset < size) {
|
||||||
|
// skip deleted dives
|
||||||
|
if (array_uint16_be(data + offset) == 0x5A23) {
|
||||||
|
offset += RECORD_SIZE;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// Get the address of the dive.
|
// Get the address of the dive.
|
||||||
unsigned int address = array_uint32_be (data + offset + 20);
|
unsigned int address = array_uint32_be (data + offset + 20);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user