Add an exception for devices without a logbook ringbuffer.

For devices without a logbook ringbuffer, such as the Oceanic Veo 1.0
and the Aeris XR-1 NX, the ringbuffer begin and end are identical. In
this case, the changes in the previous commit will always result in a
fatal error due to an invalid ringbuffer pointer. To avoid the error, we
exit before trying to use the pointers.
This commit is contained in:
Jef Driesen 2015-07-12 22:04:44 +02:00
parent cfc1a68b0d
commit 76bd9783d4

View File

@ -205,6 +205,9 @@ oceanic_common_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac
progress.maximum = 2 * PAGESIZE +
(layout->rb_profile_end - layout->rb_profile_begin) +
(layout->rb_logbook_end - layout->rb_logbook_begin);
if (layout->rb_logbook_begin == layout->rb_logbook_end) {
progress.maximum -= PAGESIZE;
}
device_event_emit (abstract, DC_EVENT_PROGRESS, &progress);
// Emit a vendor event.
@ -235,6 +238,13 @@ oceanic_common_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac
devinfo.serial = id[11] * 10000 + id[12] * 100 + id[13];
device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo);
// For devices without a logbook ringbuffer, downloading dives isn't
// possible. This is not considered a fatal error, but handled as if there
// are no dives present.
if (layout->rb_logbook_begin == layout->rb_logbook_end) {
return DC_STATUS_SUCCESS;
}
// Read the pointer data.
unsigned char pointers[PAGESIZE] = {0};
rc = dc_device_read (abstract, layout->cf_pointers, pointers, sizeof (pointers));