mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 00:13:24 +00:00
Importing salinity and atmospheric pressure from DC.
One cannot expect #ifdef to work with enum values. So the code for getting the salinity was basically never compiled in. And it was putting it in the wrong location anyway (in the dive struct instead of the divecomputer struct where it is expected). I took the opportunity to add the reading of the atmospheric pressure as well. Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
30f315fc55
commit
b79a8ec386
1 changed files with 16 additions and 4 deletions
|
@ -467,16 +467,28 @@ static int dive_cb(const unsigned char *data, unsigned int size,
|
|||
return rc;
|
||||
}
|
||||
|
||||
#ifdef DC_FIELD_SALINITY
|
||||
// Check if the libdivecomputer version already supports salinity
|
||||
double salinity = 1.03;
|
||||
#if DC_VERSION_CHECK(0, 3, 0)
|
||||
// Check if the libdivecomputer version already supports salinity & atmospheric
|
||||
dc_salinity_t salinity = {
|
||||
.type = DC_WATER_SALT,
|
||||
.density = 1.03
|
||||
};
|
||||
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;
|
||||
}
|
||||
dive->salinity = salinity * 10000.0 + 0.5;
|
||||
dive->dc.salinity = salinity.density * 10000.0 + 0.5;
|
||||
|
||||
double surface_pressure = 1.0;
|
||||
rc = dc_parser_get_field(parser, DC_FIELD_ATMOSPHERIC, 0, &surface_pressure);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
dev_info(devdata, _("Error obtaining surface pressure"));
|
||||
dc_parser_destroy(parser);
|
||||
return rc;
|
||||
}
|
||||
dive->dc.surface_pressure.mbar = surface_pressure * 1000.0 + 0.5;
|
||||
#endif
|
||||
|
||||
rc = parse_gasmixes(devdata, dive, parser, ngases, data);
|
||||
|
|
Loading…
Add table
Reference in a new issue