Fix the detection of empty dive profiles
Not only the two byte end-of-profile marker 0xFDFD is a valid empty dive profile, but also a profile with the length field present and set to 8 bytes. In that case the actual length will be just 5 bytes.
This commit is contained in:
parent
a99d990117
commit
89ae8b94cf
@ -869,7 +869,7 @@ hw_ostc3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, voi
|
||||
} else if (length == RB_LOGBOOK_SIZE_FULL + 2) {
|
||||
// A profile containing only the 2 byte end-of-profile
|
||||
// marker is considered a valid empty profile.
|
||||
} else if (length < RB_LOGBOOK_SIZE_FULL + 5 + 2 ||
|
||||
} else if (length < RB_LOGBOOK_SIZE_FULL + 5 ||
|
||||
array_uint24_le (profile + RB_LOGBOOK_SIZE_FULL) + delta != array_uint24_le (profile + HDR_FULL_LENGTH)) {
|
||||
// If there is more data available, then there should be a
|
||||
// valid profile header containing a length matching the
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libdivecomputer/units.h"
|
||||
|
||||
@ -679,8 +680,10 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
|
||||
const hw_ostc_layout_t *layout = parser->layout;
|
||||
|
||||
// Exit if no profile data available.
|
||||
if (size == header || (size == header + 2 &&
|
||||
data[header] == 0xFD && data[header + 1] == 0xFD)) {
|
||||
const unsigned char empty[] = {0x08, 0x00, 0x00, 0xFD, 0xFD};
|
||||
if (size == header ||
|
||||
(size == header + 2 && memcmp(data + header, empty + 3, 2) == 0) ||
|
||||
(size == header + 5 && memcmp(data + header, empty, 5) == 0)) {
|
||||
parser->cached = PROFILE;
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user