diff options
author | Anton Lundin <glance@acc.umu.se> | 2014-11-08 14:11:09 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-08 11:20:38 -0800 |
commit | df42f78486cd42ff48c13d9e96fe7cc33fde1887 (patch) | |
tree | 0f4c3643fd1cc52beba036dc7bd8777c67b62c71 /libdivecomputer.c | |
parent | 42d3ed0431c27b578f1e45832b0dbf3352aa96f5 (diff) | |
download | subsurface-df42f78486cd42ff48c13d9e96fe7cc33fde1887.tar.gz |
Add support for libdivecomputer DC_FIELD_DIVEMODE
libdivecomputer recently gained a api for telling us which mode the
divecomputer was running in, so this uses that to tell us if it was a OC
or CCR dive.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r-- | libdivecomputer.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c index 67d291c16..280859e50 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -569,6 +569,25 @@ static int dive_cb(const unsigned char *data, unsigned int size, } #endif +#if DC_VERSION_CHECK(0, 5, 0) && defined(DC_GASMIX_UNKNOWN) + dc_divemode_t divemode; + rc = dc_parser_get_field(parser, DC_FIELD_DIVEMODE, 0, &divemode); + if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { + dev_info(devdata, translate("gettextFromC", "Error obtaining divemode")); + goto error_exit; + } + switch(divemode) { + case DC_DIVEMODE_FREEDIVE: + case DC_DIVEMODE_GAUGE: + case DC_DIVEMODE_OC: /* Open circuit */ + dive->dc.dctype = OC; + break; + case DC_DIVEMODE_CC: /* Closed circuit */ + dive->dc.dctype = CCR; + break; + } +#endif + rc = parse_gasmixes(devdata, dive, parser, ngases, data); if (rc != DC_STATUS_SUCCESS) { dev_info(devdata, translate("gettextFromC", "Error parsing the gas mix")); |