From 76bd9783d4e5ae6030bd7685efc9ac36f394f8e7 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sun, 12 Jul 2015 22:04:44 +0200 Subject: [PATCH] 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. --- src/oceanic_common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/oceanic_common.c b/src/oceanic_common.c index e8dbba4..2dde296 100644 --- a/src/oceanic_common.c +++ b/src/oceanic_common.c @@ -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));