Skip to content

Commit

Permalink
Heinrichs Weikamp: Add logging for compass events.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeller committed Jan 11, 2025
1 parent 34556d4 commit 41238fc
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/hw_ostc_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,40 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
offset += 2;
length -= 2;
}

// Compass heading update
if (events & 0x0200) {
if (length < 2) {
ERROR (abstract->context, "Buffer overflow detected!");
return DC_STATUS_DATAFORMAT;
}

if (callback) {
unsigned int heading = array_uint16_le(data + offset);
dc_sample_value_t sample = {
.event.type = SAMPLE_EVENT_STRING,
.event.flags = SAMPLE_FLAGS_SEVERITY_INFO,
};

if (heading & 0x8000) {
sample.event.name = "Cleared compass heading";
} else {
if (heading & 0x4000) {
sample.event.type = SAMPLE_EVENT_HEADING;
sample.event.name = "Set compass heading";
} else {
sample.event.name = "Logged compass heading";
}

sample.event.value = heading & 0x1FF;
}

callback(DC_SAMPLE_EVENT, &sample, userdata);
}

offset += 2;
length -= 2;
}
}

// Extended sample info.
Expand Down

0 comments on commit 41238fc

Please sign in to comment.