From 407c40ed3821fb5504e160a48ee6f740d74a986b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Spruck?= Date: Thu, 29 Mar 2012 21:28:29 +0200 Subject: [PATCH] Fix the oxygen percentage for air dives. When the dive mode setting is set to air, the oxygen percentage stored in the header is different from the expected 21%. It might be the last used nitrox percentage. --- src/mares_nemo_parser.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/mares_nemo_parser.c b/src/mares_nemo_parser.c index 80e5bb4..7ab6feb 100644 --- a/src/mares_nemo_parser.c +++ b/src/mares_nemo_parser.c @@ -244,11 +244,23 @@ mares_nemo_parser_get_field (parser_t *abstract, parser_field_type_t type, unsig *((double *) value) = array_uint16_le (p + 53 - 10) / 10.0; break; case FIELD_TYPE_GASMIX_COUNT: - *((unsigned int *) value) = 1; + if (parser->mode == 0 || parser->mode == 1) + *((unsigned int *) value) = 1; + else + *((unsigned int *) value) = 0; break; case FIELD_TYPE_GASMIX: + switch (parser->mode) { + case 0: // Air + gasmix->oxygen = 0.21; + break; + case 1: // Nitrox + gasmix->oxygen = p[53 - 43] / 100.0; + break; + default: + return PARSER_STATUS_UNSUPPORTED; + } gasmix->helium = 0.0; - gasmix->oxygen = p[53 - 43] / 100.0; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; break; default: