From f87720dff9e04dbe03b668a85335012c4eb16f41 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 27 Nov 2017 21:58:24 +0100 Subject: [PATCH] Add support for semi-closed circuit diving Add a new type to distinguish between closed circuit (CCR) and semi-closed circuit (SCR) diving. Some dive computers from HW and DiveSystem/Ratio support this. Because the CCR/SCR abbreviations are more commonly used, let's take the opportunity to also rename the existing DC_DIVEMODE_CC. To preserve backwards compatibility, a macro is added to map the old name to the new one. Reported-by: Jan Mulder --- doc/man/dc_parser_get_field.3 | 6 ++++-- examples/output_xml.c | 2 +- include/libdivecomputer/parser.h | 6 +++++- src/atomics_cobalt_parser.c | 2 +- src/divesystem_idive_parser.c | 4 +++- src/hw_ostc_parser.c | 10 ++++++++-- src/shearwater_predator_parser.c | 2 +- src/suunto_d9_parser.c | 2 +- src/suunto_eonsteel_parser.c | 2 +- 9 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/man/dc_parser_get_field.3 b/doc/man/dc_parser_get_field.3 index 7d9e54e..2b276a1 100644 --- a/doc/man/dc_parser_get_field.3 +++ b/doc/man/dc_parser_get_field.3 @@ -172,8 +172,10 @@ for gauge (i.e., running as a record and not computing, say, decompression events), .Dv DC_DIVEMODE_OC for standard open-circuit diving, and -.Dv DC_DIVEMODE_CC -for closed-circuit +.Dv DC_DIVEMODE_CCR +and +.Dv DC_DIVEMODE_SCR +for respectively closed circuit and semi closed circuit .Dq rebreather diving. .El diff --git a/examples/output_xml.c b/examples/output_xml.c index bb88b2c..b66fc27 100644 --- a/examples/output_xml.c +++ b/examples/output_xml.c @@ -367,7 +367,7 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u } if (status != DC_STATUS_UNSUPPORTED) { - const char *names[] = {"freedive", "gauge", "oc", "cc"}; + const char *names[] = {"freedive", "gauge", "oc", "ccr", "scr"}; fprintf (output->ostream, "%s\n", names[divemode]); } diff --git a/include/libdivecomputer/parser.h b/include/libdivecomputer/parser.h index 133b252..1b53fd3 100644 --- a/include/libdivecomputer/parser.h +++ b/include/libdivecomputer/parser.h @@ -121,9 +121,13 @@ typedef enum dc_divemode_t { DC_DIVEMODE_FREEDIVE, DC_DIVEMODE_GAUGE, DC_DIVEMODE_OC, /* Open circuit */ - DC_DIVEMODE_CC /* Closed circuit */ + DC_DIVEMODE_CCR, /* Closed circuit rebreather */ + DC_DIVEMODE_SCR /* Semi-closed circuit rebreather */ } dc_divemode_t; +/* For backwards compatibility */ +#define DC_DIVEMODE_CC DC_DIVEMODE_CCR + typedef enum dc_deco_type_t { DC_DECO_NDL, DC_DECO_SAFETYSTOP, diff --git a/src/atomics_cobalt_parser.c b/src/atomics_cobalt_parser.c index e16077b..438eb39 100644 --- a/src/atomics_cobalt_parser.c +++ b/src/atomics_cobalt_parser.c @@ -202,7 +202,7 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un *((dc_divemode_t *) value) = DC_DIVEMODE_OC; break; case 1: // Closed Circuit - *((dc_divemode_t *) value) = DC_DIVEMODE_CC; + *((dc_divemode_t *) value) = DC_DIVEMODE_CCR; break; default: return DC_STATUS_DATAFORMAT; diff --git a/src/divesystem_idive_parser.c b/src/divesystem_idive_parser.c index 24f7e53..413d7c4 100644 --- a/src/divesystem_idive_parser.c +++ b/src/divesystem_idive_parser.c @@ -230,8 +230,10 @@ divesystem_idive_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, *((dc_divemode_t *) value) = DC_DIVEMODE_OC; break; case SCR: + *((dc_divemode_t *) value) = DC_DIVEMODE_SCR; + break; case CCR: - *((dc_divemode_t *) value) = DC_DIVEMODE_CC; + *((dc_divemode_t *) value) = DC_DIVEMODE_CCR; break; case GAUGE: *((dc_divemode_t *) value) = DC_DIVEMODE_GAUGE; diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index 04b9d6f..acf1592 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -59,6 +59,7 @@ #define OSTC3_CC 1 #define OSTC3_GAUGE 2 #define OSTC3_APNEA 3 +#define OSTC3_PSCR 4 #define OSTC4 0x3B @@ -505,8 +506,10 @@ hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned break; case OSTC_ZHL16_CC: case OSTC_ZHL16_CC_GF: + *((dc_divemode_t *) value) = DC_DIVEMODE_CCR; + break; case OSTC_PSCR_GF: - *((dc_divemode_t *) value) = DC_DIVEMODE_CC; + *((dc_divemode_t *) value) = DC_DIVEMODE_SCR; break; default: return DC_STATUS_DATAFORMAT; @@ -529,7 +532,7 @@ hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned *((dc_divemode_t *) value) = DC_DIVEMODE_OC; break; case OSTC3_CC: - *((dc_divemode_t *) value) = DC_DIVEMODE_CC; + *((dc_divemode_t *) value) = DC_DIVEMODE_CCR; break; case OSTC3_GAUGE: *((dc_divemode_t *) value) = DC_DIVEMODE_GAUGE; @@ -537,6 +540,9 @@ hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned case OSTC3_APNEA: *((dc_divemode_t *) value) = DC_DIVEMODE_FREEDIVE; break; + case OSTC3_PSCR: + *((dc_divemode_t *) value) = DC_DIVEMODE_SCR; + break; default: return DC_STATUS_DATAFORMAT; } diff --git a/src/shearwater_predator_parser.c b/src/shearwater_predator_parser.c index 8100a9f..8abd0f9 100644 --- a/src/shearwater_predator_parser.c +++ b/src/shearwater_predator_parser.c @@ -265,7 +265,7 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser) // Status flags. unsigned int status = data[offset + 11]; if ((status & OC) == 0) { - mode = DC_DIVEMODE_CC; + mode = DC_DIVEMODE_CCR; } // Gaschange. diff --git a/src/suunto_d9_parser.c b/src/suunto_d9_parser.c index 1f89fe4..09304d3 100644 --- a/src/suunto_d9_parser.c +++ b/src/suunto_d9_parser.c @@ -382,7 +382,7 @@ suunto_d9_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigne *((dc_divemode_t *) value) = DC_DIVEMODE_FREEDIVE; break; case CCR: - *((dc_divemode_t *) value) = DC_DIVEMODE_CC; + *((dc_divemode_t *) value) = DC_DIVEMODE_CCR; break; default: return DC_STATUS_DATAFORMAT; diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c index a7f817d..8a06f9d 100644 --- a/src/suunto_eonsteel_parser.c +++ b/src/suunto_eonsteel_parser.c @@ -1328,7 +1328,7 @@ static int traverse_diving_fields(suunto_eonsteel_parser_t *eon, const struct ty if (!strcmp(name, "DiveMode")) { if (!strncmp((const char *)data, "CCR", 3)) { - eon->cache.divemode = DC_DIVEMODE_CC; + eon->cache.divemode = DC_DIVEMODE_CCR; eon->cache.initialized |= 1 << DC_FIELD_DIVEMODE; } return 0;