Fix the decoding of negative temperatures.

Due to a firmware bug, negative temperatures are stored incorrectly and
a workaround is necessary to recover the correct value.
This commit is contained in:
Jef Driesen 2016-02-04 08:31:44 +01:00
parent 67a3697a4d
commit d2e150319b

View File

@ -389,7 +389,14 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Temperature (°C or °F).
unsigned int temperature = data[offset + 13];
int temperature = (signed char) data[offset + 13];
if (temperature < 0) {
// Fix negative temperatures.
temperature += 102;
if (temperature > 0) {
temperature = 0;
}
}
if (units == IMPERIAL)
sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
else