diff --git a/src/cressi_goa_parser.c b/src/cressi_goa_parser.c index 256dbc3..53263b1 100644 --- a/src/cressi_goa_parser.c +++ b/src/cressi_goa_parser.c @@ -43,6 +43,8 @@ #define FREEDIVE 2 #define GAUGE 3 +#define NGASMIXES 2 + typedef struct cressi_goa_parser_t cressi_goa_parser_t; struct cressi_goa_parser_t { @@ -174,6 +176,15 @@ cressi_goa_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsign parser->maxdepth = statistics.maxdepth; } + unsigned int ngasmixes = 0; + if (divemode == SCUBA || divemode == NITROX) { + for (unsigned int i = 0; i < NGASMIXES; ++i) { + if (data[0x20 + 2 * i] == 0) + break; + ngasmixes++; + } + } + dc_gasmix_t *gasmix = (dc_gasmix_t *) value; if (value) { @@ -185,7 +196,7 @@ cressi_goa_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsign *((double *) value) = parser->maxdepth; break; case DC_FIELD_GASMIX_COUNT: - *((unsigned int *) value) = divemode == SCUBA || divemode == NITROX ? 2 : 0; + *((unsigned int *) value) = ngasmixes; break; case DC_FIELD_GASMIX: gasmix->helium = 0.0;