From 70411048e5be207d2a68a5bdce897baa8d672a22 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 19 Nov 2021 09:08:25 +0100 Subject: [PATCH 1/3] Re-order the fields in the layout descriptor The new order of the fields matches the physical memory layout more closely. --- src/hw_ostc_parser.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index 714318b..5d9ac35 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -90,13 +90,13 @@ typedef struct hw_ostc_sample_info_t { typedef struct hw_ostc_layout_t { unsigned int datetime; unsigned int maxdepth; - unsigned int avgdepth; unsigned int divetime; - unsigned int atmospheric; - unsigned int salinity; - unsigned int duration; unsigned int temperature; + unsigned int atmospheric; unsigned int firmware; + unsigned int salinity; + unsigned int avgdepth; + unsigned int duration; } hw_ostc_layout_t; typedef struct hw_ostc_gasmix_t { @@ -139,37 +139,37 @@ static const dc_parser_vtable_t hw_ostc_parser_vtable = { static const hw_ostc_layout_t hw_ostc_layout_ostc = { 3, /* datetime */ 8, /* maxdepth */ - 45, /* avgdepth */ 10, /* divetime */ - 15, /* atmospheric */ - 43, /* salinity */ - 47, /* duration */ 13, /* temperature */ + 15, /* atmospheric */ 32, /* firmware */ + 43, /* salinity */ + 45, /* avgdepth */ + 47, /* duration */ }; static const hw_ostc_layout_t hw_ostc_layout_frog = { 9, /* datetime */ 14, /* maxdepth */ - 45, /* avgdepth */ 16, /* divetime */ - 21, /* atmospheric */ - 43, /* salinity */ - 47, /* duration */ 19, /* temperature */ + 21, /* atmospheric */ 32, /* firmware */ + 43, /* salinity */ + 45, /* avgdepth */ + 47, /* duration */ }; static const hw_ostc_layout_t hw_ostc_layout_ostc3 = { 12, /* datetime */ 17, /* maxdepth */ - 73, /* avgdepth */ 19, /* divetime */ - 24, /* atmospheric */ - 70, /* salinity */ - 75, /* duration */ 22, /* temperature */ + 24, /* atmospheric */ 48, /* firmware */ + 70, /* salinity */ + 73, /* avgdepth */ + 75, /* duration */ }; static unsigned int From 16e49eee6d441a9e494ab70d035579348a74090a Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 19 Nov 2021 09:12:51 +0100 Subject: [PATCH 2/3] Add the divemode to the layout descriptor --- src/hw_ostc_parser.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index 5d9ac35..29edcfd 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -97,6 +97,7 @@ typedef struct hw_ostc_layout_t { unsigned int salinity; unsigned int avgdepth; unsigned int duration; + unsigned int divemode; } hw_ostc_layout_t; typedef struct hw_ostc_gasmix_t { @@ -146,6 +147,7 @@ static const hw_ostc_layout_t hw_ostc_layout_ostc = { 43, /* salinity */ 45, /* avgdepth */ 47, /* duration */ + 51, /* divemode */ }; static const hw_ostc_layout_t hw_ostc_layout_frog = { @@ -158,6 +160,7 @@ static const hw_ostc_layout_t hw_ostc_layout_frog = { 43, /* salinity */ 45, /* avgdepth */ 47, /* duration */ + 51, /* divemode */ }; static const hw_ostc_layout_t hw_ostc_layout_ostc3 = { @@ -170,6 +173,7 @@ static const hw_ostc_layout_t hw_ostc_layout_ostc3 = { 70, /* salinity */ 73, /* avgdepth */ 75, /* duration */ + 82, /* divemode */ }; static unsigned int @@ -269,7 +273,7 @@ hw_ostc_parser_cache (hw_ostc_parser_t *parser) } } // The first fixed setpoint is the initial setpoint in CCR mode. - if (data[82] == OSTC3_CC) { + if (data[layout->divemode] == OSTC3_CC) { initial_setpoint = data[60]; } // Initial CNS @@ -511,7 +515,7 @@ hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned break; case DC_FIELD_DIVEMODE: if (version == 0x21) { - switch (data[51]) { + switch (data[layout->divemode]) { case OSTC_APNEA: *((dc_divemode_t *) value) = DC_DIVEMODE_FREEDIVE; break; @@ -533,7 +537,7 @@ hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned return DC_STATUS_DATAFORMAT; } } else if (version == 0x22) { - switch (data[51]) { + switch (data[layout->divemode]) { case FROG_ZHL16: case FROG_ZHL16_GF: *((dc_divemode_t *) value) = DC_DIVEMODE_OC; @@ -545,7 +549,7 @@ hw_ostc_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned return DC_STATUS_DATAFORMAT; } } else if (version == 0x23 || version == 0x24) { - switch (data[82]) { + switch (data[layout->divemode]) { case OSTC3_OC: *((dc_divemode_t *) value) = DC_DIVEMODE_OC; break; From 5e2d376627714c0786e964c53b47fb6d5bfad757 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 29 Nov 2021 14:26:57 +0100 Subject: [PATCH 3/3] Report the initial setpoint in SCR mode --- src/hw_ostc_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index 29edcfd..f1092c0 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -273,7 +273,7 @@ hw_ostc_parser_cache (hw_ostc_parser_t *parser) } } // The first fixed setpoint is the initial setpoint in CCR mode. - if (data[layout->divemode] == OSTC3_CC) { + if (data[layout->divemode] == OSTC3_CC || data[layout->divemode] == OSTC3_PSCR) { initial_setpoint = data[60]; } // Initial CNS