From f05f60c4ad4332a076cfcf86348b3bf24a676594 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 22 Dec 2018 21:28:48 +0100 Subject: [PATCH] Skip empty logbook entries On certain devices, for example the Aeris Elite T3, the logbook ringbuffer can sometimes contain an empty logbook entry in between the valid entries. Because the presence of such an empty entry is currently being interpreted as having reached the last valid entry, the download is aborted. The result is that all remaining valid entries, located after the empty entry, can't be downloaded. This can be avoided by skipping the empty entry instead of aborting the download. --- src/oceanic_common.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/oceanic_common.c b/src/oceanic_common.c index bdc2f79..4a42300 100644 --- a/src/oceanic_common.c +++ b/src/oceanic_common.c @@ -304,8 +304,7 @@ oceanic_common_device_logbook (dc_device_t *abstract, dc_event_progress_t *progr // fix this here. if (array_isequal (logbooks + offset, layout->rb_logbook_entry_size, 0xFF)) { WARNING (abstract->context, "Uninitialized logbook entries detected!"); - offset += layout->rb_logbook_entry_size; - break; + continue; } // Compare the fingerprint to identify previously downloaded entries. @@ -364,6 +363,12 @@ oceanic_common_device_profile (dc_device_t *abstract, dc_event_progress_t *progr // Move to the start of the current entry. entry -= layout->rb_logbook_entry_size; + // Skip uninitialized entries. + if (array_isequal (logbooks + entry, layout->rb_logbook_entry_size, 0xFF)) { + WARNING (abstract->context, "Skipping uninitialized logbook entry!"); + continue; + } + // Get the profile pointers. unsigned int rb_entry_first = get_profile_first (logbooks + entry, layout, pagesize); unsigned int rb_entry_last = get_profile_last (logbooks + entry, layout, pagesize); @@ -442,6 +447,12 @@ oceanic_common_device_profile (dc_device_t *abstract, dc_event_progress_t *progr // Move to the start of the current entry. entry -= layout->rb_logbook_entry_size; + // Skip uninitialized entries. + if (array_isequal (logbooks + entry, layout->rb_logbook_entry_size, 0xFF)) { + WARNING (abstract->context, "Skipping uninitialized logbook entry!"); + continue; + } + // Get the profile pointers. unsigned int rb_entry_first = get_profile_first (logbooks + entry, layout, pagesize); unsigned int rb_entry_last = get_profile_last (logbooks + entry, layout, pagesize);