From ab230fd4e0f92c8d3a60c14d70e0153a49cc0feb Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 12 Nov 2019 21:12:06 +0100 Subject: [PATCH] Fix the OSTC tank pressure decoding The tank pressure is stored with a resolution of 1 bar instead of 0.1 bar. There is however one exception. The hwOS Sport firmware used a resolution of 0.1 bar between versions 10.40 and 10.50. Unfortunately the only way to distinguish the Sport from the Tech variant is the different range of the version number (10.x vs 3.x). The consequence is that this workaround will start to produce wrong results once the firmware version number of the hwOS tech variant reaches the 10.x range. If that ever happens, this workaround should be removed again! --- src/hw_ostc_parser.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index f84e611..4d81f0c 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -918,7 +918,12 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call value = array_uint16_le (data + offset); if (value != 0) { sample.pressure.tank = tank; - sample.pressure.value = value / 10.0; + sample.pressure.value = value; + // The hwOS Sport firmware used a resolution of + // 0.1 bar between versions 10.40 and 10.50. + if (parser->model != OSTC4 && (firmware >= 0x0A28 && firmware <= 0x0A32)) { + sample.pressure.value /= 10.0; + } if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); } break;