From 49af321bc5cff5cd3b0dc0b08ebf52e37801f85e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 12 Jan 2016 22:37:46 +0100 Subject: [PATCH] Use the correct sample rate from the header. The Oceanic and Aeris F11 have a configurable sample rate. The possible sample intervals are 2, 1, 0.5 and 0.25 seconds. Since our smallest unit of time is one second, we can't represent the last two, and the extra samples will get dropped for now. --- src/oceanic_atom2_parser.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/oceanic_atom2_parser.c b/src/oceanic_atom2_parser.c index d829047..268f963 100644 --- a/src/oceanic_atom2_parser.c +++ b/src/oceanic_atom2_parser.c @@ -539,6 +539,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ unsigned int time = 0; unsigned int interval = 1; + unsigned int samplerate = 1; if (parser->mode != FREEDIVE) { unsigned int idx = 0x17; if (parser->model == A300CS || parser->model == VTX) @@ -557,6 +558,30 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ interval = 60; break; } + } else if (parser->model == F11A || parser->model == F11B) { + unsigned int idx = 0x29; + switch (data[idx] & 0x03) { + case 0: + interval = 1; + samplerate = 4; + break; + case 1: + interval = 1; + samplerate = 2; + break; + case 2: + interval = 1; + break; + case 3: + interval = 2; + break; + } + if (samplerate > 1) { + // Some models supports multiple samples per second. + // Since our smallest unit of time is one second, we can't + // represent this, and the extra samples will get dropped. + WARNING(abstract->context, "Multiple samples per second are not supported!"); + } } unsigned int samplesize = PAGESIZE / 2; @@ -635,7 +660,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ // The sample size is usually fixed, but some sample types have a // larger size. Check whether we have that many bytes available. - unsigned int length = samplesize; + unsigned int length = samplesize * samplerate; if (sampletype == 0xBB) { length = PAGESIZE; if (offset + length > size - PAGESIZE)