diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-11-16 13:18:17 +0530 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-18 06:08:37 +0000 |
commit | c7f803b8787ef449d340b7975e93ac733c5bda24 (patch) | |
tree | 909b0ce6f490ca2399e41865401679640bbf65ab /parse-xml.c | |
parent | e157f6220f4a6b8b0d38f0393d33ca1b6fe67c3c (diff) | |
download | subsurface-c7f803b8787ef449d340b7975e93ac733c5bda24.tar.gz |
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>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/parse-xml.c b/parse-xml.c index 79fd49661..37d1c25fb 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -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(); } |