Shearwater Teric: remove our local support for the TAG INFO_EVENT

This mostly reverts commit cb7f47b ("Shearwater Teric: add support for
the TAG INFO_EVENT") because upstream libdivecomputer now does this
natively as of commit 3e89e1b ("Add support for parsing info events").

Also, the way this had been done, it looks like it had basically
disabled the support for LOG_RECORD_FREEDIVE_SAMPLE, although nobody
seems to have ever complained, so presumably there aren't a lot of
freedivers using Shearwater dive computers and subsurface.

With this, our main differences with Jef are just the string interface
code, and the fact that we still stop parsing at LOG_RECORD_FINAL.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2020-09-12 12:22:50 -07:00
parent d6153a5a07
commit 39dc77d669

View File

@ -79,8 +79,6 @@
#define PREDATOR 2
#define PETREL 3
#define INFO_EVENT_TAG_LOG 38
#define UNDEFINED 0xFFFFFFFF
typedef struct shearwater_predator_parser_t shearwater_predator_parser_t;
@ -756,41 +754,6 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
while (offset + parser->samplesize <= length) {
dc_sample_value_t sample = {0};
// stop parsing if we see the end block
if (pnf && data[offset] == LOG_RECORD_FINAL && data[offset + 1] == 0xFD)
break;
if (pnf && data[offset] == LOG_RECORD_INFO_EVENT) {
// additional events defined in PNF
INFO(abstract->context, "PNF INFO_EVENT ID %u time %u W1 %u W2 %u", data[offset + 1],
array_uint32_be (data + offset + 4),
array_uint32_be (data + offset + 8),
array_uint32_be (data + offset + 12));
if (data[offset + 1] == INFO_EVENT_TAG_LOG) {
// this is a TAG
// its time is a unix timestamp, so we need to subtract the dive start time
unsigned int tag_time = array_uint32_be (data + offset + 4) - array_uint32_be (data + parser->opening[0] + 12);
unsigned int tag_heading = array_uint32_be (data + offset + 8);
unsigned int tag_type = array_uint32_be (data + offset + 12);
// heading is only valid if 0..360
// type is only valid if 0..5
if (tag_heading <= 360 && tag_type <= 5) {
// encode this as a bookmark event, using the flags to capture the type and value for heading
sample.event.type = SAMPLE_EVENT_BOOKMARK;
sample.event.time = tag_time;
sample.event.flags = (tag_type + 1) << SAMPLE_FLAGS_TYPE_SHIFT; // 0 means it isn't a tag
sample.event.value = tag_heading;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
}
}
offset += parser->samplesize;
continue;
}
// Ignore blocks that aren't dive samples
if (pnf && data[offset] != LOG_RECORD_DIVE_SAMPLE) {
offset += parser->samplesize;
continue;
}
// Ignore empty samples.
if (array_isequal (data + offset, parser->samplesize, 0x00)) {
offset += parser->samplesize;
@ -800,6 +763,10 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
// Get the record type.
unsigned int type = pnf ? data[offset] : LOG_RECORD_DIVE_SAMPLE;
// stop parsing if we see the end block
if (type == LOG_RECORD_FINAL && data[offset + 1] == 0xFD)
break;
if (type == LOG_RECORD_DIVE_SAMPLE) {
// Time (seconds).
time += interval;
@ -987,5 +954,6 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
offset += parser->samplesize;
}
return DC_STATUS_SUCCESS;
}