Shearwater Teric: add support for the TAG INFO_EVENT
This logs every INFO_EVENT record and provides a SAMPLE_EVENT_BOOKMARK event for the only INFO_EVENT we can parse so far, the TAG event. Three bits in the flag value in that event structure are now used to hold the tag type, and if a non-zero type has been set, then the value is the heading in degress. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d0ec5cf760
commit
e4698c4844
@ -124,6 +124,17 @@ typedef enum parser_sample_flags_t {
|
|||||||
#define SAMPLE_FLAGS_SEVERITY_WARN (3 << SAMPLE_FLAGS_SEVERITY_SHIFT)
|
#define SAMPLE_FLAGS_SEVERITY_WARN (3 << SAMPLE_FLAGS_SEVERITY_SHIFT)
|
||||||
#define SAMPLE_FLAGS_SEVERITY_ALARM (4 << SAMPLE_FLAGS_SEVERITY_SHIFT)
|
#define SAMPLE_FLAGS_SEVERITY_ALARM (4 << SAMPLE_FLAGS_SEVERITY_SHIFT)
|
||||||
|
|
||||||
|
/* these are used for the types of TAGs in Shearwater PNF info events */
|
||||||
|
#define SAMPLE_FLAGS_TYPE_SHIFT 5
|
||||||
|
#define SAMPLE_FLAGS_TYPE_MASK (7 << SAMPLE_FLAGS_TYPE_SHIFT)
|
||||||
|
#define SAMPLE_FLAGS_TYPE_NONE (0 << SAMPLE_FLAGS_TYPE_SHIFT)
|
||||||
|
#define SAMPLE_FLAGS_TYPE_INTEREST (1 << SAMPLE_FLAGS_TYPE_SHIFT)
|
||||||
|
#define SAMPLE_FLAGS_TYPE_NAVPOINT (2 << SAMPLE_FLAGS_TYPE_SHIFT)
|
||||||
|
#define SAMPLE_FLAGS_TYPE_DANGER (3 << SAMPLE_FLAGS_TYPE_SHIFT)
|
||||||
|
#define SAMPLE_FLAGS_TYPE_ANIMAL (4 << SAMPLE_FLAGS_TYPE_SHIFT)
|
||||||
|
#define SAMPLE_FLAGS_TYPE_ISSUE (5 << SAMPLE_FLAGS_TYPE_SHIFT)
|
||||||
|
#define SAMPLE_FLAGS_TYPE_INJURY (6 << SAMPLE_FLAGS_TYPE_SHIFT)
|
||||||
|
|
||||||
typedef enum parser_sample_vendor_t {
|
typedef enum parser_sample_vendor_t {
|
||||||
SAMPLE_VENDOR_NONE,
|
SAMPLE_VENDOR_NONE,
|
||||||
SAMPLE_VENDOR_UWATEC_ALADIN,
|
SAMPLE_VENDOR_UWATEC_ALADIN,
|
||||||
|
|||||||
@ -58,6 +58,7 @@
|
|||||||
#define LOG_RECORD_CLOSING_5 0x25
|
#define LOG_RECORD_CLOSING_5 0x25
|
||||||
#define LOG_RECORD_CLOSING_6 0x26
|
#define LOG_RECORD_CLOSING_6 0x26
|
||||||
#define LOG_RECORD_CLOSING_7 0x27
|
#define LOG_RECORD_CLOSING_7 0x27
|
||||||
|
#define LOG_RECORD_INFO_EVENT 0x30
|
||||||
#define LOG_RECORD_FINAL 0xFF
|
#define LOG_RECORD_FINAL 0xFF
|
||||||
|
|
||||||
#define SZ_BLOCK 0x80
|
#define SZ_BLOCK 0x80
|
||||||
@ -81,6 +82,8 @@
|
|||||||
#define PREDATOR 2
|
#define PREDATOR 2
|
||||||
#define PETREL 3
|
#define PETREL 3
|
||||||
|
|
||||||
|
#define INFO_EVENT_TAG_LOG 38
|
||||||
|
|
||||||
#define UNDEFINED 0xFFFFFFFF
|
#define UNDEFINED 0xFFFFFFFF
|
||||||
|
|
||||||
typedef struct shearwater_predator_parser_t shearwater_predator_parser_t;
|
typedef struct shearwater_predator_parser_t shearwater_predator_parser_t;
|
||||||
@ -759,6 +762,32 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
|
|||||||
if (pnf && data[offset] == LOG_RECORD_FINAL && data[offset + 1] == 0xFD)
|
if (pnf && data[offset] == LOG_RECORD_FINAL && data[offset + 1] == 0xFD)
|
||||||
break;
|
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
|
// Ignore blocks that aren't dive samples
|
||||||
if (pnf && data[offset] != LOG_RECORD_DIVE_SAMPLE) {
|
if (pnf && data[offset] != LOG_RECORD_DIVE_SAMPLE) {
|
||||||
offset += parser->samplesize;
|
offset += parser->samplesize;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user