Fix the Aeris 500AI logbook read command
The two bytes in the command to read the logbook index are most likely not a single 16 bit number, but two 8 bit numbers specifiying a range. The same pattern can be found in the logbook pointers.
This commit is contained in:
parent
aa2dbac509
commit
f42449b101
@ -312,21 +312,25 @@ oceanic_aeris500ai_device_logbook (dc_device_t *abstract, dc_event_progress_t *p
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the logbook pointers.
|
// Get the logbook pointers.
|
||||||
|
unsigned int first = pointers[0x02];
|
||||||
unsigned int last = pointers[0x03];
|
unsigned int last = pointers[0x03];
|
||||||
|
|
||||||
|
// Get the number of dives.
|
||||||
|
unsigned int ndives = last - first + 1;
|
||||||
|
|
||||||
// Update and emit a progress event.
|
// Update and emit a progress event.
|
||||||
progress->current += PAGESIZE;
|
progress->current += PAGESIZE;
|
||||||
progress->maximum += PAGESIZE + (last + 1) * PAGESIZE / 2;
|
progress->maximum += PAGESIZE + ndives * PAGESIZE / 2;
|
||||||
device_event_emit (abstract, DC_EVENT_PROGRESS, progress);
|
device_event_emit (abstract, DC_EVENT_PROGRESS, progress);
|
||||||
|
|
||||||
// Allocate memory for the logbook entries.
|
// Allocate memory for the logbook entries.
|
||||||
if (!dc_buffer_reserve (logbook, (last + 1) * PAGESIZE / 2))
|
if (!dc_buffer_reserve (logbook, ndives * PAGESIZE / 2))
|
||||||
return DC_STATUS_NOMEMORY;
|
return DC_STATUS_NOMEMORY;
|
||||||
|
|
||||||
// Send the logbook index command.
|
// Send the logbook index command.
|
||||||
unsigned char command[] = {0x52,
|
unsigned char command[] = {0x52,
|
||||||
(last >> 8) & 0xFF, // high
|
first & 0xFF,
|
||||||
(last ) & 0xFF, // low
|
last & 0xFF,
|
||||||
0x00};
|
0x00};
|
||||||
rc = oceanic_vtpro_transfer (device, command, sizeof (command), NULL, 0);
|
rc = oceanic_vtpro_transfer (device, command, sizeof (command), NULL, 0);
|
||||||
if (rc != DC_STATUS_SUCCESS) {
|
if (rc != DC_STATUS_SUCCESS) {
|
||||||
@ -335,7 +339,7 @@ oceanic_aeris500ai_device_logbook (dc_device_t *abstract, dc_event_progress_t *p
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the logbook index.
|
// Read the logbook index.
|
||||||
for (unsigned int i = 0; i < last + 1; ++i) {
|
for (unsigned int i = 0; i < ndives; ++i) {
|
||||||
// Receive the answer of the dive computer.
|
// Receive the answer of the dive computer.
|
||||||
unsigned char answer[PAGESIZE / 2 + 1] = {0};
|
unsigned char answer[PAGESIZE / 2 + 1] = {0};
|
||||||
rc = dc_iostream_read (device->iostream, answer, sizeof(answer), NULL);
|
rc = dc_iostream_read (device->iostream, answer, sizeof(answer), NULL);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user