From 5d6408ed2fcc031136fe8c2c61be92b096c48e4a Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 21 Feb 2014 09:17:11 +0100 Subject: [PATCH] Ignore uninitialized header entries Normally, the OSTC3 will always start writing dives at the first entry in the TOC (Table of Contents). Therefore, uninitialized entries can only be present after the last dive. However due to a minor firmware bug, resetting the logbook erases the TOC but leaves the internal dive counter unchanged. The consequence is that the next dive will still be stored at the corresponding next TOC entry, while all previous TOC entries have been erased. As a workaround, we simply ignore uninitialized entries, unless we have already found at least one dive. --- src/hw_ostc3.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hw_ostc3.c b/src/hw_ostc3.c index 1bcc73f..a2bac63 100644 --- a/src/hw_ostc3.c +++ b/src/hw_ostc3.c @@ -374,8 +374,12 @@ hw_ostc3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, voi unsigned int offset = i * RB_LOGBOOK_SIZE; // Ignore uninitialized header entries. - if (array_isequal (header + offset, RB_LOGBOOK_SIZE, 0xFF)) - break; + if (array_isequal (header + offset, RB_LOGBOOK_SIZE, 0xFF)) { + if (count) + break; + else + continue; + } // Get the internal dive number. unsigned int current = array_uint16_le (header + offset + 80);