mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
4e88140b43
commit
6b904f9480
1 changed files with 37 additions and 13 deletions
50
ostctools.c
50
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.
|
||||
|
|
Loading…
Add table
Reference in a new issue