[PATCH] Cochran import: Removed long tail of 0 depth from profile

John Van Ostrand john at vanostrand.com
Wed May 31 19:08:48 PDT 2017


The Cochran logs the first 10 to 20 minutes (configurable) of
surface interval in case the diver re-submerges.

Signed-off-by: John Van Ostrand <john at vanostrand.com>
---
 core/cochran.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/core/cochran.c b/core/cochran.c
index 76beae1..af7d09b 100644
--- a/core/cochran.c
+++ b/core/cochran.c
@@ -644,6 +644,7 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
 
 	unsigned int sample_size = size - 0x4914 - config.logbook_size;
 	int g;
+	unsigned int sample_pre_offset = 0, sample_end_offset = 0;
 
 	// Decode sample data
 	partial_decode(0x4914 + config.logbook_size, size, decode,
@@ -715,6 +716,9 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
 		if (log[CMD_MAX_DEPTH] == 0xff && log[CMD_MAX_DEPTH + 1] == 0xff)
 			corrupt_dive = 1;
 
+		sample_pre_offset = array_uint32_le(log + CMD_PREDIVE_OFFSET);
+		sample_end_offset = array_uint32_le(log + CMD_END_OFFSET);
+
 		break;
 	case TYPE_EMC:
 		dc->model = "EMC";
@@ -756,9 +760,17 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
 		if (log[EMC_MAX_DEPTH] == 0xff && log[EMC_MAX_DEPTH + 1] == 0xff)
 			corrupt_dive = 1;
 
+		sample_pre_offset = array_uint32_le(log + EMC_PREDIVE_OFFSET);
+		sample_end_offset = array_uint32_le(log + EMC_END_OFFSET);
+
 		break;
 	}
 
+	// Use the log information to determine actual profile sample size
+	// Otherwise we will get surface time at end of dive.
+	if (sample_pre_offset < sample_end_offset && sample_end_offset != 0xffffffff)
+		sample_size = sample_end_offset - sample_pre_offset;
+
 	cochran_parse_samples(dive, buf + 0x4914, buf + 0x4914
 		+ config.logbook_size, sample_size,
 		&duration, &max_depth, &avg_depth, &min_temp);
-- 
2.4.11



More information about the subsurface mailing list