First patch limits the EON steel pressure and temperature samples to
somewhat sensible values. (I still need to dig into this more to understand
where the bogus data comes from, is it my parsing or is it in the DB.)

The second removes some unused variables from the DM5 import.

miika
From 48692396bf7cd616c42fbb97e0698badd3302a3e Mon Sep 17 00:00:00 2001
From: Miika Turkia <[email protected]>
Date: Tue, 18 Nov 2014 11:05:07 +0545
Subject: [PATCH 2/2] Remove unused variables

Signed-off-by: Miika Turkia <[email protected]>
---
 parse-xml.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/parse-xml.c b/parse-xml.c
index 37d1c25..0223611 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -2016,9 +2016,6 @@ extern int dm5_dive(void *param, int columns, char **data, char **column)
 {
 	int i, interval, retval = 0;
 	sqlite3 *handle = (sqlite3 *)param;
-	float *profileBlob;
-	unsigned char *tempBlob;
-	int *pressureBlob;
 	unsigned const char *sampleBlob;
 	char *err = NULL;
 	char get_events_template[] = "select * from Mark where DiveId = %d";
@@ -2084,9 +2081,6 @@ extern int dm5_dive(void *param, int columns, char **data, char **column)
 		cur_dive->dc.surface_pressure.mbar = (atoi(data[14]) * 1000);
 
 	interval = data[16] ? atoi(data[16]) : 0;
-	profileBlob = (float *)(data[17] + 3);
-	tempBlob = (unsigned char *)(data[17] + 10);
-	pressureBlob = (int *)(data[17] + 7);
 	sampleBlob = (unsigned const char *)data[17];
 	for (i = 0; interval && i * interval < cur_dive->duration.seconds; i++) {
 		float *depth = (float *)&sampleBlob[i * 16 + 3];
-- 
1.9.1

From 7786ee0c645d8687fa2ab1fe5328c29faaf39932 Mon Sep 17 00:00:00 2001
From: Miika Turkia <[email protected]>
Date: Sun, 16 Nov 2014 13:18:17 +0530
Subject: [PATCH 1/2] Limit pressure and temperature values

Limit temperatures and cylinder pressures to somewhat sensible values.

Signed-off-by: Miika Turkia <[email protected]>
---
 parse-xml.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/parse-xml.c b/parse-xml.c
index 79fd496..37d1c25 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();
 	}
 
-- 
1.9.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to