diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2015-06-02 06:33:51 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-02 10:48:46 -0700 |
commit | 16ac0bc45d0eac6444e6f4cf9325105eeeb92bdd (patch) | |
tree | 64f22a175ccdf15839aa172ca80627834b9dcaf1 /parse-xml.c | |
parent | 0ae40b406993966610b31b8166c64065a8792d4c (diff) | |
download | subsurface-16ac0bc45d0eac6444e6f4cf9325105eeeb92bdd.tar.gz |
Support for changed DM5 sample blob
Block size for sample is now variable, so detect the version and parse
proper blocks.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/parse-xml.c b/parse-xml.c index c3da4fa68..1fbde0bf0 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -2268,7 +2268,7 @@ extern int dm4_dive(void *param, int columns, char **data, char **column) extern int dm5_dive(void *param, int columns, char **data, char **column) { - int i, interval, retval = 0; + int i, interval, retval = 0, block_size; sqlite3 *handle = (sqlite3 *)param; unsigned const char *sampleBlob; char *err = NULL; @@ -2330,10 +2330,25 @@ extern int dm5_dive(void *param, int columns, char **data, char **column) interval = data[16] ? atoi(data[16]) : 0; sampleBlob = (unsigned const char *)data[24]; + + if (sampleBlob) { + switch (sampleBlob[0]) { + case 2: + block_size = 19; + break; + case 3: + block_size = 23; + break; + default: + block_size = 16; + break; + } + } + for (i = 0; interval && sampleBlob && i * interval < cur_dive->duration.seconds; i++) { - float *depth = (float *)&sampleBlob[i * 16 + 3]; - int32_t temp = (sampleBlob[i * 16 + 10] << 8) + sampleBlob[i * 16 + 11]; - int32_t pressure = (sampleBlob[i * 16 + 9] << 16) + (sampleBlob[i * 16 + 8] << 8) + sampleBlob[i * 16 + 7]; + float *depth = (float *)&sampleBlob[i * block_size + 3]; + int32_t temp = (sampleBlob[i * block_size + 10] << 8) + sampleBlob[i * block_size + 11]; + int32_t pressure = (sampleBlob[i * block_size + 9] << block_size) + (sampleBlob[i * block_size + 8] << 8) + sampleBlob[i * block_size + 7]; sample_start(); cur_sample->time.seconds = i * interval; |