summaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2015-08-18 07:35:23 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-17 21:41:19 -0700
commit2e8286623d3f4e1b8bf3a4d5141cda0839d1d506 (patch)
tree17f456d0dd2ad91b48370a7af3661a46ba89f167 /file.c
parent56c90efba8748f162da0ba1b4e9b9331e1748124 (diff)
downloadsubsurface-2e8286623d3f4e1b8bf3a4d5141cda0839d1d506.tar.gz
Fix MKVI erroneous sample time
There was a bug in MKVI download tool that resulted in erroneous sample times. This fix takes care of that and should work similarly as the vendor's own. Fixes #916 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'file.c')
-rw-r--r--file.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/file.c b/file.c
index 8522b2e38..f612656f9 100644
--- a/file.c
+++ b/file.c
@@ -552,6 +552,7 @@ int parse_txt_file(const char *filename, const char *csv)
bool has_depth = false, has_setpoint = false, has_ndl = false;
char *lineptr, *key, *value;
int o2cylinder_pressure = 0, cylinder_pressure = 0, cur_cylinder_index = 0;
+ unsigned int prev_time = 0;
struct dive *dive;
struct divecomputer *dc;
@@ -651,7 +652,14 @@ int parse_txt_file(const char *filename, const char *csv)
has_setpoint = false;
has_ndl = false;
sample = prepare_sample(dc);
- sample->time.seconds = cur_sampletime;
+
+ /*
+ * There was a bug in MKVI download tool that resulted in erroneous sample
+ * times. This fix should work similarly as the vendor's own.
+ */
+
+ sample->time.seconds = cur_sampletime < 0xFFFF * 3 / 4 ? cur_sampletime : prev_time;
+ prev_time = sample->time.seconds;
do {
int i = sscanf(lineptr, "%d,%d,%d", &sampletime, &type, &value);