Add support for the Uwatec Galileo Trimix.

This commit is contained in:
Jef Driesen 2011-05-07 14:13:50 +02:00
parent 074bee70a2
commit ddf6fca65f

View File

@ -37,6 +37,7 @@
#define ALADINTEC2G 0x13
#define SMARTCOM 0x14
#define SMARTTEC 0x18
#define GALILEOTRIMIX 0x19
#define SMARTZ 0x1C
typedef struct uwatec_smart_parser_t uwatec_smart_parser_t;
@ -207,6 +208,7 @@ uwatec_smart_parser_get_field (parser_t *abstract, parser_field_type_t type, uns
unsigned int size = abstract->size;
unsigned int header = 0;
unsigned int trimix = 0;
const uwatec_smart_header_info_t *table = NULL;
// Load the correct table.
@ -216,7 +218,12 @@ uwatec_smart_parser_get_field (parser_t *abstract, parser_field_type_t type, uns
table = &uwatec_smart_pro_header;
break;
case GALILEO:
case GALILEOTRIMIX:
header = 152;
if (data[43] & 0x80) {
header = 0xB1;
trimix = 1;
}
table = &uwatec_galileo_sol_header;
break;
case ALADINTEC:
@ -257,7 +264,10 @@ uwatec_smart_parser_get_field (parser_t *abstract, parser_field_type_t type, uns
*((double *) value) = array_uint16_le (data + table->maxdepth) / 100.0;
break;
case FIELD_TYPE_GASMIX_COUNT:
*((unsigned int *) value) = table->ngases;
if (trimix)
*((unsigned int *) value) = 0;
else
*((unsigned int *) value) = table->ngases;
break;
case FIELD_TYPE_GASMIX:
gasmix->helium = 0.0;
@ -340,6 +350,8 @@ typedef enum {
BEARING,
ALARMS,
TIME,
UNKNOWN1,
UNKNOWN2,
} uwatec_smart_sample_t;
typedef struct uwatec_smart_sample_info_t {
@ -429,6 +441,8 @@ uwatec_smart_sample_info_t uwatec_galileo_sol_table [] = {
{HEARTRATE, 1, 0, 8, 0, 1}, // 1111 0111 dddddddd
{BEARING, 1, 0, 8, 0, 2}, // 1111 1000 dddddddd dddddddd
{ALARMS, 1, 2, 8, 0, 1}, // 1111 1001 dddddddd
{UNKNOWN1, 1, 0, 8, 0, 0}, // 1111 1010 (8 bytes)
{UNKNOWN2, 1, 0, 8, 0, 1}, // 1111 1011 dddddddd (n-1 bytes)
};
static parser_status_t
@ -445,6 +459,7 @@ uwatec_smart_parser_samples_foreach (parser_t *abstract, sample_callback_t callb
const uwatec_smart_sample_info_t *table = NULL;
unsigned int entries = 0;
unsigned int header = 0;
unsigned int trimix = 0;
// Load the correct table.
switch (parser->model) {
@ -454,7 +469,12 @@ uwatec_smart_parser_samples_foreach (parser_t *abstract, sample_callback_t callb
entries = NELEMENTS (uwatec_smart_pro_table);
break;
case GALILEO:
case GALILEOTRIMIX:
header = 152;
if (data[43] & 0x80) {
header = 0xB1;
trimix = 1;
}
table = uwatec_galileo_sol_table;
entries = NELEMENTS (uwatec_galileo_sol_table);
break;
@ -515,7 +535,7 @@ uwatec_smart_parser_samples_foreach (parser_t *abstract, sample_callback_t callb
// Process the type bits in the bitstream.
unsigned int id = 0;
if (parser->model == GALILEO) {
if (parser->model == GALILEO || parser->model == GALILEOTRIMIX) {
// Uwatec Galileo
id = uwatec_galileo_identify (data[offset]);
} else {
@ -588,8 +608,13 @@ uwatec_smart_parser_samples_foreach (parser_t *abstract, sample_callback_t callb
break;
case PRESSURE:
if (table[id].absolute) {
tank = table[id].index;
pressure = value / 4.0;
if (trimix) {
tank = (value & 0xF000) >> 24;
pressure = (value & 0x0FFF) / 4.0;
} else {
tank = table[id].index;
pressure = value / 4.0;
}
have_pressure = 1;
} else {
pressure += svalue / 4.0;
@ -627,6 +652,20 @@ uwatec_smart_parser_samples_foreach (parser_t *abstract, sample_callback_t callb
case TIME:
complete = value;
break;
case UNKNOWN1:
if (offset + 8 > size) {
WARNING ("Incomplete sample data.");
return PARSER_STATUS_ERROR;
}
offset += 8;
break;
case UNKNOWN2:
if (value < 1 || offset + value - 1 > size) {
WARNING ("Incomplete sample data.");
return PARSER_STATUS_ERROR;
}
offset += value - 1;
break;
default:
WARNING ("Unknown sample type.");
break;