From 25411672dc1395d614d78477cdb653f62ecb921d Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 7 Nov 2014 21:18:11 +0100 Subject: [PATCH] Implement tank support for the Mares Darwin Air. --- src/mares_darwin_parser.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/mares_darwin_parser.c b/src/mares_darwin_parser.c index 183df48..5de4c4b 100644 --- a/src/mares_darwin_parser.c +++ b/src/mares_darwin_parser.c @@ -38,6 +38,7 @@ typedef struct mares_darwin_parser_t mares_darwin_parser_t; struct mares_darwin_parser_t { dc_parser_t base; + unsigned int model; unsigned int headersize; unsigned int samplesize; }; @@ -74,6 +75,8 @@ mares_darwin_parser_create (dc_parser_t **out, dc_context_t *context, unsigned i // Initialize the base class. parser_init (&parser->base, context, &mares_darwin_parser_vtable); + parser->model = model; + if (model == DARWINAIR) { parser->headersize = 60; parser->samplesize = 3; @@ -139,6 +142,7 @@ mares_darwin_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi const unsigned char *p = abstract->data; dc_gasmix_t *gasmix = (dc_gasmix_t *) value; + dc_tank_t *tank = (dc_tank_t *) value; if (value) { switch (type) { @@ -159,6 +163,25 @@ mares_darwin_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi case DC_FIELD_TEMPERATURE_MINIMUM: *((double *) value) = (signed char) p[0x0A]; break; + case DC_FIELD_TANK_COUNT: + if (parser->model == DARWINAIR) { + *((unsigned int *) value) = 1; + } else { + *((unsigned int *) value) = 0; + } + break; + case DC_FIELD_TANK: + if (parser->model == DARWINAIR) { + tank->type = DC_TANKVOLUME_METRIC; + tank->volume = p[0x13] / 10.0; + tank->workpressure = 0.0; + tank->gasmix = 0; + tank->beginpressure = array_uint16_be (p + 0x17); + tank->endpressure = array_uint16_be (p + 0x19); + } else { + return DC_STATUS_UNSUPPORTED; + } + break; default: return DC_STATUS_UNSUPPORTED; }