diff options
author | Salvador Cuñat <salvador.cunat@gmail.com> | 2015-07-12 20:30:06 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-07-12 13:58:17 -0700 |
commit | 6b904f94805249bc2409dbb4c64fcaba87b95148 (patch) | |
tree | 6e1e617fa3cd5dcf42ce8c503b19968855168e2c /ostctools.c | |
parent | 4e88140b433fcb7b545126b5c3e439b431eb6dd8 (diff) | |
download | subsurface-6b904f94805249bc2409dbb4c64fcaba87b95148.tar.gz |
OSTCTools - change management of model and dc family
H&W introduced some changes in dc's data structures with FROG and OSTC3
families (types 0x22 and 0x23 in H&W's terms) that I didn't take into
account as we lacked of .dive files to test.
BTW I previously set the model to "0" as it was not stored in the file
but wasn't relevant for the data parsing in MK2, OSTC and OSTC2N/2C
models.
Thanks to Anton's advice we have got some OSTC3 dives to test, so this
patch takes into account the different data structures for different
families, and try to stablish a model number based on device's serial
number, as libdc does.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'ostctools.c')
-rw-r--r-- | ostctools.c | 50 |
1 files changed, 37 insertions, 13 deletions
diff --git a/ostctools.c b/ostctools.c index 0bb00ee9f..0ae29191a 100644 --- a/ostctools.c +++ b/ostctools.c @@ -108,20 +108,44 @@ void ostctools_import(const char *file, struct dive_table *divetable) } // Try to determine the dc family based on the header type - switch (buffer[2]) { - case 0x20: - case 0x21: + if (buffer[2] == 0x20 || buffer[2] == 0x21) dc_fam = DC_FAMILY_HW_OSTC; - break; - case 0x22: - dc_fam = DC_FAMILY_HW_FROG; - break; - case 0x23: - dc_fam = DC_FAMILY_HW_OSTC3; - break; - default: - fprintf(stderr, "got unknown dc family %x\n", buffer[2]); - dc_fam = DC_FAMILY_NULL; + else { + switch (buffer[8]) { + case 0x22: + dc_fam = DC_FAMILY_HW_FROG; + break; + case 0x23: + dc_fam = DC_FAMILY_HW_OSTC3; + break; + default: + report_error(translate("gettextFromC", "Unknown DC in dive %d"), ostcdive->number); + free(ostcdive); + fclose(archive); + goto out; + } + } + + // Try to determine the model based on serial number + switch (dc_fam) { + case DC_FAMILY_HW_OSTC: + if (serial > 7000) + model = 3; //2C + else if (serial > 2048) + model = 2; //2N + else if (serial > 300) + model = 1; //MK2 + else + model = 0; //OSTC + break; + case DC_FAMILY_HW_FROG: + model = 0; + break; + default: + if (serial > 10000) + model = 0x12; //Sport + else + model = 0x0A; //OSTC3 } // Prepare data to pass to libdivecomputer. |