summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c11
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();
}