So I finally have dives and tried to download them, and due to an
annoying bug in a warning printout, it just crashed instead.

I fixed the missing argument to the warning printout and it all worked
(with the warning that not all of the sample data was parsed), and
then I also added the parsing code for the missing fields so that the
warning went away, and the resultant patch is attached.

So this is the final piece to actually have working EON Steel
downloads with the new firmware. And actually tested too. Yay.

Dirk, do you want me to re-send the three previous patches, or do you
have them pending somewhere?

                     Linus
From b068a22a87bcb31d0bdc4a18d3e0e7dc103944ba Mon Sep 17 00:00:00 2001
From: Linus Torvalds <[email protected]>
Date: Sun, 14 Jun 2015 14:20:05 -1000
Subject: [PATCH 4/4] EON Steel: fix up missing gastime/ventilation parsing

Now that I actually have dives with the new format and with air
integration, I could test it all out and noticed some missing pieces.

This adds parsing for gastime and ventilation events (although we don't
*do* anything with the ventilation data, I have no idea what the number
means).

Also, this fixes an annoying warning message problem, which caused these
missing events to cause a SIGSEGV rather than just a bening warning.
Stupid bug, and only went unnoticed because libdivecomputer isn't built
with format string warnings.

Signed-off-by: Linus Torvalds <[email protected]>
---
 src/suunto_eonsteel_parser.c | 42 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)

diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c
index 1c4f9c28aba5..7f6a246f0f2e 100644
--- a/src/suunto_eonsteel_parser.c
+++ b/src/suunto_eonsteel_parser.c
@@ -48,6 +48,8 @@ enum eon_sample {
 	ES_tts,		// uint16,nillable=65535 (time to surface)
 	ES_heading,	// uint16,precision=4,nillable=65535 (heading in degrees)
 	ES_abspressure,	// uint16,precision=0,nillable=65535 (abs presure in centibar)
+	ES_gastime,	// int16,nillable=-1 (remaining gas time in minutes)
+	ES_ventilation,	// uint16,precision=6,nillable=65535 ("x/6000000,x"? No idea)
 	ES_gasnr,	// uint8
 	ES_pressure,	// uint16,nillable=65535 (cylinder pressure in centibar)
 	ES_state,
@@ -104,8 +106,8 @@ static const struct {
 	{ "TimeToSurface",			ES_tts },
 	{ "Heading",				ES_heading },
 	{ "DeviceInternalAbsPressure",		ES_abspressure },
-	{ "GasTime",				ES_none },
-	{ "Ventilation",			ES_none },
+	{ "GasTime",				ES_gastime },
+	{ "Ventilation",			ES_ventilation },
 	{ "Cylinders+Cylinder.GasNumber",	ES_gasnr },
 	{ "Cylinders.Cylinder.Pressure",	ES_pressure },
 	{ "Events+State.Type",			ES_state },
@@ -223,10 +225,11 @@ static int fill_in_group_details(suunto_eonsteel_parser_t *eon, struct type_desc
 			grp = end+1;
 			continue;
 		default:
-			ERROR(eon->base.context, "Group type descriptor '%s' has undescribed index %d", desc->desc, index);
+			ERROR(eon->base.context, "Group type descriptor '%s' has unparseable index %d", desc->desc, index);
 			return -1;
 		}
 	}
+	return -1;
 }
 
 /*
@@ -510,6 +513,29 @@ static void sample_abspressure(struct sample_data *info, unsigned short pressure
 {
 }
 
+static void sample_gastime(struct sample_data *info, short gastime)
+{
+	dc_sample_value_t sample = {0};
+
+	if (gastime < 0)
+		return;
+
+	sample.event.type = SAMPLE_EVENT_AIRTIME;
+	sample.event.value = gastime;
+	if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata);
+}
+
+/*
+ * Per-sample "ventilation" data.
+ *
+ * It's described as:
+ *   - "uint16,precision=6,nillable=65535"
+ *   - "x/6000000,x"
+ */
+static void sample_ventilation(struct sample_data *info, unsigned short unk)
+{
+}
+
 static void sample_gasnr(struct sample_data *info, unsigned char idx)
 {
 	info->gasnr = idx;
@@ -739,6 +765,14 @@ static int handle_sample_type(struct sample_data *info, enum eon_sample type, co
 		sample_abspressure(info, array_uint16_le(data));
 		return 2;
 
+	case ES_gastime:
+		sample_gastime(info, array_uint16_le(data));
+		return 2;
+
+	case ES_ventilation:
+		sample_ventilation(info, array_uint16_le(data));
+		return 2;
+
 	case ES_gasnr:
 		sample_gasnr(info, *data);
 		return 1;
@@ -831,7 +865,7 @@ static int traverse_samples(unsigned short type, const struct type_desc *desc, c
 
 	// Warn if there are left-over bytes for something we did use part of
 	if (used && len)
-		ERROR(eon->base.context, "Entry for '%s' had %d bytes, only used %d", len+used, used);
+		ERROR(eon->base.context, "Entry for '%s' had %d bytes, only used %d", desc->desc, len+used, used);
 	return 0;
 }
 
-- 
2.4.2.387.gf86f31a

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

Reply via email to