Fix the gas mix parsing for the Aladin Tec 2G.

Unlike the other models, the Aladin Tec 2G uses only a single byte to
store the oxygen percentage, and there is no need to manually re-map the
deco mix.

Normally, the oxygen percentage is stored using two bytes (little endian
byte order). Thus for a device supporting two gas mixes, four bytes will
be used, and the corresponding gas mix id for each byte is as follows:

  ID: 0 0 1 1

After re-mapping the id of the deco mix, this becomes:

  ID: 0 0 2 2

Since oxygen percentages are limited to the range 0-100%, the highest
byte (marked with an X) should always be zero and can thus be ignored:

  ID: 0 X 2 X

Now, because an oxygen percentage of zero indicates a disabled gas mix,
this is equivalent to a device supporting three (or even four) gas
mixes, each stored using only a single byte:

  ID: 0 1 2 3

We can take advantage of this knowledge to avoid having to re-map the
deco mix id.
This commit is contained in:
Jef Driesen 2016-08-19 08:23:47 +02:00
parent 3b179e7058
commit decfa24f92

View File

@ -211,7 +211,7 @@ static const
uwatec_smart_header_info_t uwatec_smart_aladin_tec2g_header = {
22,
26,
34, 2,
34, 3,
30, /* temp_minimum */
28, /* temp_maximum */
32, /* temp_surface */
@ -483,17 +483,17 @@ uwatec_smart_parser_cache (uwatec_smart_parser_t *parser)
uwatec_smart_gasmix_t gasmix[NGASMIXES] = {{0}};
if (!trimix) {
for (unsigned int i = 0; i < header->ngases; ++i) {
unsigned int id = i;
if (id > 0 && header->ngases == 2) {
id++; // Remap the id of the deco mix.
unsigned int idx = DC_GASMIX_UNKNOWN;
unsigned int o2 = 0;
if (parser->model == ALADINTEC2G) {
o2 = data[header->gasmix + i];
} else {
o2 = array_uint16_le (data + header->gasmix + i * 2);
}
unsigned int idx = DC_GASMIX_UNKNOWN;
unsigned int o2 = data[header->gasmix + i * 2];
if (o2 != 0) {
idx = ngasmixes;
gasmix[ngasmixes].id = id;
gasmix[ngasmixes].id = i;
gasmix[ngasmixes].oxygen = o2;
gasmix[ngasmixes].helium = 0;
ngasmixes++;
@ -517,7 +517,7 @@ uwatec_smart_parser_cache (uwatec_smart_parser_t *parser)
}
if ((beginpressure != 0 || endpressure != 0) &&
(beginpressure != 0xFFFF) && (endpressure != 0xFFFF)) {
tank[ntanks].id = id;
tank[ntanks].id = i;
tank[ntanks].beginpressure = beginpressure;
tank[ntanks].endpressure = endpressure;
tank[ntanks].gasmix = idx;