From 6b912f4f7b7bf99c5ebd61ca72bcfdf5dc60f65a Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 7 Apr 2014 11:05:14 +0200 Subject: [PATCH] Fix the detection of the last valid dive. Normally, the last valid dive is followed by an empty entry with all 0xFF bytes. However, we received data from a device where a few of those bytes are not equal to 0xFF. This causes the entry to be processed incorrectly as a valid dive. As a workaround, we now check the internal dive number for 0xFFFF. --- src/cressi_leonardo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cressi_leonardo.c b/src/cressi_leonardo.c index b295098..9bee775 100644 --- a/src/cressi_leonardo.c +++ b/src/cressi_leonardo.c @@ -314,6 +314,10 @@ cressi_leonardo_extract_dives (dc_device_t *abstract, const unsigned char data[] // Get the internal dive number. unsigned int current = array_uint16_le (data + offset); + if (current == 0xFFFF) { + WARNING (context, "Unexpected internal dive number found."); + break; + } if (current > maximum) { maximum = current; latest = i;