diff --git a/examples/universal.c b/examples/universal.c index 2f5d616..2b0fc81 100644 --- a/examples/universal.c +++ b/examples/universal.c @@ -467,6 +467,22 @@ doparse (FILE *fp, dc_device_t *device, const unsigned char data[], unsigned int tank.beginpressure, tank.endpressure); } + // Parse the dive mode. + message ("Parsing the dive mode.\n"); + dc_divemode_t divemode = DC_DIVEMODE_OC; + rc = dc_parser_get_field (parser, DC_FIELD_DIVEMODE, 0, &divemode); + if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { + WARNING ("Error parsing the dive mode."); + dc_parser_destroy (parser); + return rc; + } + + if (rc != DC_STATUS_UNSUPPORTED) { + const char *names[] = {"freedive", "gauge", "oc", "cc"}; + fprintf (fp, "%s\n", + names[divemode]); + } + // Parse the salinity. message ("Parsing the salinity.\n"); dc_salinity_t salinity = {DC_WATER_FRESH, 0.0}; diff --git a/include/libdivecomputer/parser.h b/include/libdivecomputer/parser.h index 63dc113..f1f73bd 100644 --- a/include/libdivecomputer/parser.h +++ b/include/libdivecomputer/parser.h @@ -58,7 +58,8 @@ typedef enum dc_field_type_t { DC_FIELD_TEMPERATURE_MINIMUM, DC_FIELD_TEMPERATURE_MAXIMUM, DC_FIELD_TANK_COUNT, - DC_FIELD_TANK + DC_FIELD_TANK, + DC_FIELD_DIVEMODE } dc_field_type_t; typedef enum parser_sample_event_t { @@ -115,6 +116,13 @@ typedef enum dc_water_t { DC_WATER_SALT } dc_water_t; +typedef enum dc_divemode_t { + DC_DIVEMODE_FREEDIVE, + DC_DIVEMODE_GAUGE, + DC_DIVEMODE_OC, /* Open circuit */ + DC_DIVEMODE_CC /* Closed circuit */ +} dc_divemode_t; + typedef enum dc_deco_type_t { DC_DECO_NDL, DC_DECO_SAFETYSTOP,