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.
This commit is contained in:
Jef Driesen 2010-12-25 20:09:23 +01:00
parent 3afc32b499
commit bb8255a116

View File

@ -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;