diff --git a/src/suunto_d9_parser.c b/src/suunto_d9_parser.c index 020a7dc..67fa49a 100644 --- a/src/suunto_d9_parser.c +++ b/src/suunto_d9_parser.c @@ -42,6 +42,12 @@ #define D6i 0x1A #define D9tx 0x1B +#define AIR 0 +#define NITROX 1 +#define GAUGE 2 +#define FREEDIVE 3 +#define MIXED 4 + typedef struct suunto_d9_parser_t suunto_d9_parser_t; struct suunto_d9_parser_t { @@ -185,6 +191,14 @@ suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsign if (size < config) return PARSER_STATUS_ERROR; + // Gas model + unsigned int gasmodel_offset = 0x1D - SKIP; + if (parser->model == HELO2) + gasmodel_offset += 6; + if (parser->model == D4i || parser->model == D6i || parser->model == D9tx) + gasmodel_offset = 0x1D; + unsigned int gasmodel = data[gasmodel_offset]; + gasmix_t *gasmix = (gasmix_t *) value; if (value) { @@ -203,7 +217,9 @@ suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsign *((double *) value) = array_uint16_le (data + 0x0D - SKIP) / 100.0; break; case FIELD_TYPE_GASMIX_COUNT: - if (parser->model == HELO2) { + if (gasmodel == AIR) { + *((unsigned int *) value) = 1; + } else if (parser->model == HELO2) { *((unsigned int *) value) = 8; } else if (parser->model == D9tx) { *((unsigned int *) value) = 8; @@ -216,7 +232,10 @@ suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsign } break; case FIELD_TYPE_GASMIX: - if (parser->model == HELO2) { + if (gasmodel == AIR) { + gasmix->helium = 0.0; + gasmix->oxygen = 0.21; + } else if (parser->model == HELO2) { gasmix->helium = data[0x58 - SKIP + 6 * flags + 2] / 100.0; gasmix->oxygen = data[0x58 - SKIP + 6 * flags + 1] / 100.0; } else if (parser->model == D9tx) {