From bb8255a116e718ce1bccd97b5e2cbdd25326f189 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 25 Dec 2010 20:09:23 +0100 Subject: [PATCH] Search for the end of te profile ringbuffer. Because some devices appear to store the end-of-profile pointer at different locations, we search all know positions for a valid value. --- src/mares_iconhd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mares_iconhd.c b/src/mares_iconhd.c index 2a2e23e..28b3e2d 100644 --- a/src/mares_iconhd.c +++ b/src/mares_iconhd.c @@ -319,7 +319,13 @@ mares_iconhd_extract_dives (device_t *abstract, const unsigned char data[], unsi return DEVICE_STATUS_ERROR; // Get the end of the profile ring buffer. - unsigned int eop = array_uint32_le (data + 0x2001); + unsigned int eop = 0; + const unsigned int config[] = {0x2001, 0x3001}; + for (unsigned int i = 0; i < sizeof (config) / sizeof (*config); ++i) { + eop = array_uint32_le (data + config[i]); + if (eop != 0xFFFFFFFF) + break; + } if (eop < RB_PROFILE_BEGIN || eop >= RB_PROFILE_END) { WARNING ("Ringbuffer pointer out of range."); return DEVICE_STATUS_ERROR;