Limit pressure and temperature values

Limit temperatures and cylinder pressures to somewhat sensible values.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2014-11-16 13:18:17 +05:30 committed by Dirk Hohndel
parent e157f6220f
commit c7f803b878

View file

@ -2090,15 +2090,20 @@ extern int dm5_dive(void *param, int columns, char **data, char **column)
sampleBlob = (unsigned const char *)data[17];
for (i = 0; interval && i * interval < cur_dive->duration.seconds; i++) {
float *depth = (float *)&sampleBlob[i * 16 + 3];
int32_t temp = (sampleBlob[i * 16 + 10] << 8) + sampleBlob[i * 16 + 11];
int32_t pressure = (sampleBlob[i * 16 + 9] << 16) + (sampleBlob[i * 16 + 8] << 8) + sampleBlob[i * 16 + 7];
sample_start();
cur_sample->time.seconds = i * interval;
cur_sample->depth.mm = depth[0] * 1000;
cur_sample->temperature.mkelvin = C_to_mkelvin(temp);
cur_sample->cylinderpressure.mbar = pressure;
/*
* Limit temperatures and cylinder pressures to somewhat
* sensible values
*/
if (temp >= -10 && temp < 50)
cur_sample->temperature.mkelvin = C_to_mkelvin(temp);
if (pressure >= 0 && pressure < 350000)
cur_sample->cylinderpressure.mbar = pressure;
sample_end();
}