|
47 | 47 | #define ID_LOG_VERSION 0x0F
|
48 | 48 | #define ID_TRIM 0x10
|
49 | 49 | #define ID_GAS_CONFIG 0x11
|
| 50 | +#define ID_TANK_TRANSMITTER 0x12 |
| 51 | +#define ID_GF_INFO 0x13 |
50 | 52 |
|
51 | 53 | #define ISCONFIG(type) ( \
|
52 | 54 | (type) == ID_LOG_VERSION || \
|
|
65 | 67 | #define NGASMIXES 10
|
66 | 68 | #define NTANKS 10
|
67 | 69 |
|
| 70 | +#define TRANSMITTER_ID (1u << 16) |
| 71 | + |
68 | 72 | typedef struct halcyon_symbios_gasmix_t {
|
69 | 73 | unsigned int id;
|
70 | 74 | unsigned int oxygen;
|
@@ -305,6 +309,8 @@ halcyon_symbios_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
|
305 | 309 | 4, /* ID_LOG_VERSION */
|
306 | 310 | 4, /* ID_TRIM */
|
307 | 311 | 8, /* ID_GAS_CONFIG */
|
| 312 | + 8, /* ID_TANK_TRANSMITTER */ |
| 313 | + 6, /* ID_GF_INFO */ |
308 | 314 | };
|
309 | 315 |
|
310 | 316 | unsigned int time_start = UNDEFINED, time_end = UNDEFINED;
|
@@ -632,6 +638,49 @@ halcyon_symbios_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
|
632 | 638 | if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata);
|
633 | 639 | }
|
634 | 640 | }
|
| 641 | + } else if (type == ID_TANK_TRANSMITTER) { |
| 642 | + unsigned int id = data[offset + 2] | TRANSMITTER_ID; |
| 643 | + unsigned int DC_ATTR_UNUSED battery = array_uint16_le (data + offset + 4); |
| 644 | + unsigned int pressure = array_uint16_le (data + offset + 6) / 10; |
| 645 | + dc_usage_t usage = DC_USAGE_NONE; |
| 646 | + |
| 647 | + if (tank_id_previous != id || |
| 648 | + tank_usage_previous != usage) { |
| 649 | + // Find the tank in the list. |
| 650 | + unsigned int idx = 0; |
| 651 | + while (idx < ntanks) { |
| 652 | + if (tank[idx].id == id && |
| 653 | + tank[idx].usage == usage) |
| 654 | + break; |
| 655 | + idx++; |
| 656 | + } |
| 657 | + |
| 658 | + // Add a new tank if necessary. |
| 659 | + if (idx >= ntanks) { |
| 660 | + if (ngasmixes >= NTANKS) { |
| 661 | + ERROR (abstract->context, "Maximum number of tanks reached."); |
| 662 | + return DC_STATUS_NOMEMORY; |
| 663 | + } |
| 664 | + tank[ntanks].id = id; |
| 665 | + tank[ntanks].beginpressure = pressure; |
| 666 | + tank[ntanks].endpressure = pressure; |
| 667 | + tank[ntanks].gasmix = DC_GASMIX_UNKNOWN; |
| 668 | + tank[ntanks].usage = usage; |
| 669 | + ntanks++; |
| 670 | + } |
| 671 | + |
| 672 | + tank_id_previous = id; |
| 673 | + tank_usage_previous = usage; |
| 674 | + tank_idx = idx; |
| 675 | + } |
| 676 | + tank[tank_idx].endpressure = pressure; |
| 677 | + |
| 678 | + sample.pressure.tank = tank_idx; |
| 679 | + sample.pressure.value = pressure / 10.0; |
| 680 | + if (callback) callback(DC_SAMPLE_PRESSURE, &sample, userdata); |
| 681 | + } else if (type == ID_GF_INFO) { |
| 682 | + unsigned int DC_ATTR_UNUSED gf_now = array_uint16_le (data + offset + 2); |
| 683 | + unsigned int DC_ATTR_UNUSED gf_surface = array_uint16_le (data + offset + 4); |
635 | 684 | } else {
|
636 | 685 | WARNING (abstract->context, "Unknown record (type=%u, size=%u", type, length);
|
637 | 686 | }
|
|
0 commit comments