summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2017-08-07 23:42:03 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-08-10 09:09:53 -0700
commit070c7e545bbc34bbc7c6a17f4cb587f5b0801ea1 (patch)
treefa35862af32bbc9e458da4559f980d0e1a1bf6ce
parent8f6f9cd39d4485a2c4aa71eeb71d9ab9bc1c1fa2 (diff)
downloadsubsurface-070c7e545bbc34bbc7c6a17f4cb587f5b0801ea1.tar.gz
DLF: Parse Divesoft Liberty data better
There is something with ndl / tts / temp in the Liberty DLF files. If that bit is set, the values are bogus. There is something more to it here which I haven't figured out. Signed-off-by: Anton Lundin <glance@acc.umu.se>
-rw-r--r--core/parse-xml.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/core/parse-xml.c b/core/parse-xml.c
index 86de629aa..da897cd3c 100644
--- a/core/parse-xml.c
+++ b/core/parse-xml.c
@@ -3565,18 +3565,22 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size)
// because we rather calculate ppo2 our selfs.
if (cur_dc->divemode == CCR || cur_dc->divemode == PSCR)
cur_sample->o2sensor[0].mbar = ((ptr[7] << 8) + ptr[6]) / 10;
- // NDL in minutes, 10 bit
- cur_sample->ndl.seconds = (((ptr[9] & 0x03) << 8) + ptr[8]) * 60;
- // TTS in minutes, 10 bit
- cur_sample->tts.seconds = (((ptr[10] & 0x0F) << 6) + (ptr[9] >> 2)) * 60;
- // Temperature in 1/10 C, 10 bit signed
- cur_sample->temperature.mkelvin = ((ptr[11] & 0x20) ? -1 : 1) * (((ptr[11] & 0x1F) << 4) + (ptr[10] >> 4)) * 100 + ZERO_C_IN_MKELVIN;
- // ptr[11] & 0xF0 is unknown, and always 0xC in all checked files
+
+ // In some test files, ndl / tts / temp is bogus if this bits are 1
+ // flag bits in ptr[11] & 0xF0 is probably involved to,
+ if ((ptr[2] >> 5) != 1) {
+ // NDL in minutes, 10 bit
+ cur_sample->ndl.seconds = (((ptr[9] & 0x03) << 8) + ptr[8]) * 60;
+ // TTS in minutes, 10 bit
+ cur_sample->tts.seconds = (((ptr[10] & 0x0F) << 6) + (ptr[9] >> 2)) * 60;
+ // Temperature in 1/10 C, 10 bit signed
+ cur_sample->temperature.mkelvin = ((ptr[11] & 0x20) ? -1 : 1) * (((ptr[11] & 0x1F) << 4) + (ptr[10] >> 4)) * 100 + ZERO_C_IN_MKELVIN;
+ }
cur_sample->stopdepth.mm = ((ptr[13] << 8) + ptr[12]) * 10;
if (cur_sample->stopdepth.mm)
cur_sample->in_deco = true;
//ptr[14] is helium content, always zero?
- //ptr[15] is setpoint, always zero?
+ //ptr[15] is setpoint, what the computer thinks you should aim for?
sample_end();
break;
case 1: /* dive event */