summaryrefslogtreecommitdiffstats
path: root/libdivecomputer.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-10 19:18:10 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-10 19:22:22 +0100
commitf53788e5e4066f0ef36041031de6bc2726274fc9 (patch)
tree8d87d01759a85a53647476cfd693e56cc2fdd24f /libdivecomputer.c
parent836bbad7a6c87c00fd99a14117f0d7b5fc8f9d7a (diff)
downloadsubsurface-f53788e5e4066f0ef36041031de6bc2726274fc9.tar.gz
Add support for obtaining salinity from libdivecomputer
This requires a patched libdivecomputer that can return salinity of the water the dive was conducted in. Experimental patches exist that implement this for the OSTC. The code is designed so that it simply defaults to salt water if libdivecomputer doesn't include the feature. The patch also fixes the dive merge code to merge two other recent additions to the dive structure (surface_pressure and visibility). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r--libdivecomputer.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c
index e3153572a..6a9b07f80 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -281,6 +281,18 @@ static int dive_cb(const unsigned char *data, unsigned int size,
return rc;
}
+ // Check if the libdivecomputer version already supports salinity
+ double salinity = 1.03;
+#ifdef DC_FIELD_SALINITY
+ rc = dc_parser_get_field(parser, DC_FIELD_SALINITY, 0, &salinity);
+ if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
+ dev_info(devdata, _("Error obtaining water salinity"));
+ dc_parser_destroy(parser);
+ return rc;
+ }
+#endif
+ dive->salinity = salinity * 10000.0 + 0.5;
+
rc = parse_gasmixes(devdata, dive, parser, ngases);
if (rc != DC_STATUS_SUCCESS) {
dev_info(devdata, _("Error parsing the gas mix"));