[PATCH] Cochran: Fixed duplicate gasmix event reports

John Van Ostrand john at vanostrand.com
Sun Jul 2 07:07:45 PDT 2017


Newer cochran DCs record a gas change event at the begining of a
dive. The code creates a gas change before processing samples so
with newer DCs this resulted in duplicate events.
---
 src/cochran_commander_parser.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/cochran_commander_parser.c b/src/cochran_commander_parser.c
index 9340d01..b58a6c4 100644
--- a/src/cochran_commander_parser.c
+++ b/src/cochran_commander_parser.c
@@ -568,6 +568,7 @@ cochran_commander_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callb
 
 	sample.gasmix = 0;
 	if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata);
+	unsigned int last_gasmix = sample.gasmix;
 
 	while (offset < size) {
 		const unsigned char *s = samples + offset;
@@ -631,12 +632,18 @@ cochran_commander_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callb
 				break;
 			case 0xCD:  // Switched to deco blend
 			case 0xEF:  // Switched to gas blend 2
-				sample.gasmix = 1;
-				if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata);
+				if (last_gasmix != 1) {
+					sample.gasmix = 1;
+					if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata);
+					last_gasmix = sample.gasmix;
+				}
 				break;
 			case 0xF3:  // Switched to gas blend 1
-				sample.gasmix = 0;
-				if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata);
+				if (last_gasmix != 0) {
+					sample.gasmix = 0;
+					if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata);
+					last_gasmix = sample.gasmix;
+				}
 				break;
 			}
 
-- 
2.4.11



More information about the devel mailing list