diff --git a/src/mares_iconhd_parser.c b/src/mares_iconhd_parser.c index 9ac6dd6..cb67504 100644 --- a/src/mares_iconhd_parser.c +++ b/src/mares_iconhd_parser.c @@ -401,12 +401,12 @@ mares_iconhd_cache (mares_iconhd_parser_t *parser) unsigned int samplerate = 0; if (parser->model == SMARTAPNEA) { unsigned int idx = (settings & 0x0600) >> 9; - interval = 1; samplerate = 1 << idx; + interval = 1000 / samplerate; } else { const unsigned int intervals[] = {1, 5, 10, 20}; unsigned int idx = (settings & 0x0C00) >> 10; - interval = intervals[idx]; + interval = intervals[idx] * 1000; samplerate = 1; } @@ -625,7 +625,7 @@ mares_genius_cache (mares_iconhd_parser_t *parser) parser->headersize = headersize; parser->settings = settings; parser->surftime = surftime * 60; - parser->interval = 5; + parser->interval = 5000; parser->samplerate = 1; parser->ntanks = ntanks; parser->ngasmixes = ngasmixes; @@ -820,7 +820,7 @@ mares_iconhd_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi if (parser->layout->divetime != UNSUPPORTED) { *((unsigned int *) value) = array_uint16_le (p + parser->layout->divetime); } else { - *((unsigned int *) value) = parser->nsamples * parser->interval - parser->surftime; + *((unsigned int *) value) = parser->nsamples * parser->interval / 1000 - parser->surftime; } break; case DC_FIELD_MAXDEPTH: @@ -963,14 +963,6 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t const unsigned char *data = abstract->data; - if (parser->samplerate > 1) { - // The Smart Apnea supports multiple samples per second - // (e.g. 2, 4 or 8). 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!"); - } - // Previous gas mix - initialize with impossible value unsigned int gasmix_previous = 0xFFFFFFFF; @@ -1021,8 +1013,8 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t unsigned int surftime = array_uint16_le (data + offset + 4); // Surface Time (seconds). - time += surftime; - sample.time = time * 1000; + time += surftime * 1000; + sample.time = time; if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Surface Depth (0 m). @@ -1032,10 +1024,11 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t offset += parser->samplesize; nsamples++; - for (unsigned int i = 0; i < divetime; ++i) { + unsigned int count = divetime * parser->samplerate; + for (unsigned int i = 0; i < count; ++i) { // Time (seconds). time += parser->interval; - sample.time = time * 1000; + sample.time = time; if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (1/10 m). @@ -1043,7 +1036,7 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t sample.depth = depth / 10.0; if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); - offset += 2 * parser->samplerate; + offset += 2; } } else if (parser->model != GENIUS && parser->model != HORIZON && parser->mode == ICONHD_FREEDIVE) { unsigned int maxdepth = array_uint16_le (data + offset + 0); @@ -1051,8 +1044,8 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t unsigned int surftime = array_uint16_le (data + offset + 4); // Surface Time (seconds). - time += surftime; - sample.time = time * 1000; + time += surftime * 1000; + sample.time = time; if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Surface Depth (0 m). @@ -1060,8 +1053,8 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); // Dive Time (seconds). - time += divetime; - sample.time = time * 1000; + time += divetime * 1000; + sample.time = time; if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Maximum Depth (1/10 m). @@ -1123,7 +1116,7 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t // Time (seconds). time += parser->interval; - sample.time = time * 1000; + sample.time = time; if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (1/10 m). diff --git a/src/oceanic_atom2_parser.c b/src/oceanic_atom2_parser.c index ed4edd4..526a10f 100644 --- a/src/oceanic_atom2_parser.c +++ b/src/oceanic_atom2_parser.c @@ -608,8 +608,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ unsigned int extratime = 0; unsigned int time = 0; - unsigned int interval = 1; - unsigned int samplerate = 1; + unsigned int interval = 1000; if (parser->mode != FREEDIVE) { unsigned int offset = 0x17; if (parser->model == A300CS || parser->model == VTX || @@ -617,21 +616,13 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ parser->model == PROPLUSX || parser->model == I770R || parser->model == SAGE || parser->model == BEACON) offset = 0x1f; - const unsigned int intervals[] = {2, 15, 30, 60}; + const unsigned int intervals[] = {2000, 15000, 30000, 60000}; unsigned int idx = data[offset] & 0x03; interval = intervals[idx]; } else if (parser->model == F11A || parser->model == F11B) { - const unsigned int intervals[] = {1, 1, 1, 2}; - const unsigned int samplerates[] = {4, 2, 1, 1}; + const unsigned int intervals[] = {250, 500, 1000, 2000}; unsigned int idx = data[0x29] & 0x03; interval = intervals[idx]; - samplerate = samplerates[idx]; - 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; @@ -752,13 +743,13 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ // The surface time is not always a nice multiple of the samplerate. // The number of inserted surface samples is therefore rounded down // to keep the timestamps aligned at multiples of the samplerate. - unsigned int surftime = 60 * bcd2dec (data[offset + 1]) + bcd2dec (data[offset + 2]); + unsigned int surftime = (60 * bcd2dec (data[offset + 1]) + bcd2dec (data[offset + 2])) * 1000; unsigned int nsamples = surftime / interval; for (unsigned int i = 0; i < nsamples; ++i) { // Time time += interval; - sample.time = time * 1000; + sample.time = time; if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Vendor specific data @@ -777,19 +768,12 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ extratime += surftime; } else { - // Skip the extra samples. - if ((count % samplerate) != 0) { - offset += samplesize; - count++; - continue; - } - // Time. if (parser->model == I450T || parser->model == I470TC) { unsigned int minute = bcd2dec(data[offset + 0]); unsigned int hour = bcd2dec(data[offset + 1] & 0x0F); unsigned int second = bcd2dec(data[offset + 2]); - unsigned int timestamp = (hour * 3600) + (minute * 60 ) + second + extratime; + unsigned int timestamp = ((hour * 3600) + (minute * 60 ) + second) * 1000 + extratime; if (timestamp < time) { ERROR (abstract->context, "Timestamp moved backwards."); return DC_STATUS_DATAFORMAT; @@ -802,7 +786,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ } else { time += interval; } - sample.time = time * 1000; + sample.time = time; if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Vendor specific data diff --git a/src/shearwater_predator_parser.c b/src/shearwater_predator_parser.c index cd98e76..0975ff9 100644 --- a/src/shearwater_predator_parser.c +++ b/src/shearwater_predator_parser.c @@ -871,14 +871,9 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal // Sample interval. unsigned int time = 0; - unsigned int interval = 10; + unsigned int interval = 10000; if (parser->pnf && parser->logversion >= 9 && parser->opening[5] != UNDEFINED) { interval = array_uint16_be (data + parser->opening[5] + 23); - if (interval % 1000 != 0) { - ERROR (abstract->context, "Unsupported sample interval (%u ms).", interval); - return DC_STATUS_DATAFORMAT; - } - interval /= 1000; } unsigned int pnf = parser->pnf; @@ -899,7 +894,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal if (type == LOG_RECORD_DIVE_SAMPLE) { // Time (seconds). time += interval; - sample.time = time * 1000; + sample.time = time; if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (1/10 m or ft). @@ -1076,7 +1071,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal // Time (seconds). time += interval; - sample.time = time * 1000; + sample.time = time; if (callback) callback (DC_SAMPLE_TIME, sample, userdata); // Depth (absolute pressure in millibar) diff --git a/src/suunto_eonsteel_parser.c b/src/suunto_eonsteel_parser.c index 31f67b9..c7276fb 100644 --- a/src/suunto_eonsteel_parser.c +++ b/src/suunto_eonsteel_parser.c @@ -474,7 +474,7 @@ static void sample_time(struct sample_data *info, unsigned short time_delta) dc_sample_value_t sample = {0}; info->time += time_delta; - sample.time = info->time / 1000 * 1000; + sample.time = info->time; if (info->callback) info->callback(DC_SAMPLE_TIME, sample, info->userdata); }