[PATCH] Eliminate packed struct for Cochran

John Van Ostrand john at vanostrand.com
Wed Oct 29 08:14:44 PDT 2014


Removed the packed struct and replaced with byte offsets.
Fixed salinity for EMC.
Added start temp for CMDR and Gemini.

Signed-off-by: John Van Ostrand <john at vanostrand.com>
---
 cochran.c      | 121 ++++++++++++++++++++--------------------
 cochran.h      |  45 +++++++++++++++
 cochran_cmdr.h |  82 ---------------------------
 cochran_emc.h  | 171 ---------------------------------------------------------
 subsurface.pro |   3 +-
 5 files changed, 106 insertions(+), 316 deletions(-)
 create mode 100644 cochran.h
 delete mode 100644 cochran_cmdr.h
 delete mode 100644 cochran_emc.h

diff --git a/cochran.c b/cochran.c
index 011d405..0ff6437 100644
--- a/cochran.c
+++ b/cochran.c
@@ -10,8 +10,7 @@
 #include "file.h"
 #include "units.h"
 #include "gettext.h"
-#include "cochran_emc.h"
-#include "cochran_cmdr.h"
+#include "cochran.h"
 #include "divelist.h"
 
 #include <libdivecomputer/parser.h>
@@ -445,30 +444,29 @@ static void cochran_parse_samples(struct dive *dive, const unsigned char *log,
 	struct divecomputer *dc = &dive->dc;
 	struct sample *sample;
 
-	const struct cochran_cmdr_log_t *log_cmdr = (struct cochran_cmdr_log_t *) log;
-	const struct cochran_emc_log_t *log_emc = (struct cochran_emc_log_t *) log;
-
 	// Initialize stat variables
 	*max_depth = 0, *avg_depth = 0, *min_temp = 0xFF;
 
 	// Get starting depth and temp (tank PSI???)
 	switch (config.type) {
 	case TYPE_GEMINI:
-		depth = (float)(log_cmdr->start_depth[0]
-			+ log_cmdr->start_depth[1] * 256) / 4;
-		psi = log_cmdr->start_psi[0] + log_cmdr->start_psi[1] * 256;
-		sgc_rate = (float)(log_cmdr->start_sgc[0]
-			+ log_cmdr->start_sgc[1] * 256) / 2;
+		depth = (float) (log[CMD_START_DEPTH]
+			+ log[CMD_START_DEPTH + 1] * 256) / 4;
+		temp = log[CMD_START_TEMP];
+		psi = log[CMD_START_PSI] + log[CMD_START_PSI + 1] * 256;
+		sgc_rate = (float)(log[CMD_START_SGC]
+			+ log[CMD_START_SGC + 1] * 256) / 2;
 		break;
 	case TYPE_COMMANDER:
-		depth = (float)(log_cmdr->start_depth[0]
-			+ log_cmdr->start_depth[1] * 256) / 4;
+		depth = (float) (log[CMD_START_DEPTH]
+			+ log[CMD_START_DEPTH + 1] * 256) / 4;
+		temp = log[CMD_START_TEMP];
 		break;
 
 	case TYPE_EMC:
-		depth = (float)log_emc->start_depth[0] / 256
-			+ log_emc->start_depth[1];
-		temp = log_emc->start_temperature;
+		depth = (float) log [EMC_START_DEPTH] / 256
+			+ log[EMC_START_DEPTH + 1];
+		temp = log[EMC_START_TEMP];
 		break;
 	}
 
@@ -656,8 +654,7 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
 	dive = alloc_dive();
 	dc = &dive->dc;
 
-	struct cochran_cmdr_log_t *cmdr_log = (struct cochran_cmdr_log_t *) (buf + 0x4914);
-	struct cochran_emc_log_t *emc_log = (struct cochran_emc_log_t *) (buf + 0x4914);
+	unsigned char *log = (buf + 0x4914);
 
 	switch (config.type) {
 	case TYPE_GEMINI:
@@ -666,45 +663,45 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
 			dc->model = "Gemini";
 			dc->deviceid = buf[0x18c] * 256 + buf[0x18d];	// serial no
 			fill_default_cylinder(&dive->cylinder[0]);
-			dive->cylinder[0].gasmix.o2.permille = (cmdr_log->o2_percent[0][0] / 256
-				+ cmdr_log->o2_percent[0][1]) * 10;
+			dive->cylinder[0].gasmix.o2.permille = (log[CMD_O2_PERCENT] / 256
+				+ log[CMD_O2_PERCENT + 1]) * 10;
 			dive->cylinder[0].gasmix.he.permille = 0;
 		} else {
 			dc->model = "Commander";
 			dc->deviceid = array_uint32_le(buf + 0x31e);	// serial no
 			for (g = 0; g < 2; g++) {
 				fill_default_cylinder(&dive->cylinder[g]);
-				dive->cylinder[g].gasmix.o2.permille = (cmdr_log->o2_percent[g][0] / 256
-					+ cmdr_log->o2_percent[g][1]) * 10;
+				dive->cylinder[g].gasmix.o2.permille = (log[CMD_O2_PERCENT + g * 2] / 256
+					+ log[CMD_O2_PERCENT + g * 2 + 1]) * 10;
 				dive->cylinder[g].gasmix.he.permille = 0;
 			}
 		}
 
-		tm.tm_year = cmdr_log->year;
-		tm.tm_mon = cmdr_log->month - 1;
-		tm.tm_mday = cmdr_log->day;
-		tm.tm_hour = cmdr_log->hour;
-		tm.tm_min = cmdr_log->minutes;
-		tm.tm_sec = cmdr_log->seconds;
+		tm.tm_year = log[CMD_YEAR];
+		tm.tm_mon = log[CMD_MON] - 1;
+		tm.tm_mday = log[CMD_DAY];
+		tm.tm_hour = log[CMD_HOUR];
+		tm.tm_min = log[CMD_MIN];
+		tm.tm_sec = log[CMD_SEC];
 		tm.tm_isdst = -1;
 
 		dive->when = dc->when = utc_mktime(&tm);
-		dive->number = cmdr_log->number[0] + cmdr_log->number[1] * 256 + 1;
-		dc->duration.seconds = (cmdr_log->bt[0] + cmdr_log->bt[1] * 256) * 60;
-		dc->surfacetime.seconds = (cmdr_log->sit[0] + cmdr_log->sit[1] * 256) * 60;
-		dc->maxdepth.mm = (cmdr_log->max_depth[0] +
-			cmdr_log->max_depth[1] * 256) / 4 * FEET * 1000;
-		dc->meandepth.mm = (cmdr_log->avg_depth[0] +
-			cmdr_log->avg_depth[1] * 256) / 4 * FEET * 1000;
-		dc->watertemp.mkelvin = C_to_mkelvin((cmdr_log->temp / 32) - 1.8);
+		dive->number = log[CMD_NUMBER] + log[CMD_NUMBER + 1] * 256 + 1;
+		dc->duration.seconds = (log[CMD_BT] + log[CMD_BT + 1] * 256) * 60;
+		dc->surfacetime.seconds = (log[CMD_SIT] + log[CMD_SIT + 1] * 256) * 60;
+		dc->maxdepth.mm = (log[CMD_MAX_DEPTH] +
+			log[CMD_MAX_DEPTH + 1] * 256) / 4 * FEET * 1000;
+		dc->meandepth.mm = (log[CMD_AVG_DEPTH] +
+			log[CMD_AVG_DEPTH + 1] * 256) / 4 * FEET * 1000;
+		dc->watertemp.mkelvin = C_to_mkelvin((log[CMD_MIN_TEMP] / 32) - 1.8);
 		dc->surface_pressure.mbar = ATM / BAR * pow(1 - 0.0000225577
-			* (double) cmdr_log->altitude * 250 * FEET, 5.25588) * 1000;
-		dc->salinity = 10000 + 150 * emc_log->water_conductivity;
+			* (double) log[CMD_ALTITUDE] * 250 * FEET, 5.25588) * 1000;
+		dc->salinity = 10000 + 150 * log[CMD_WATER_CONDUCTIVITY];
 
-		SHA1(cmdr_log->number, 2, (unsigned char *)csum);
+		SHA1(log + CMD_NUMBER, 2, (unsigned char *)csum);
 		dc->diveid = csum[0];
 
-		if (cmdr_log->max_depth[0] == 0xff && cmdr_log->max_depth[1] == 0xff)
+		if (log[CMD_MAX_DEPTH] == 0xff && log[CMD_MAX_DEPTH + 1] == 0xff)
 			corrupt_dive = 1;
 
 		break;
@@ -713,37 +710,39 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod,
 		dc->deviceid = array_uint32_le(buf + 0x31e);	// serial no
 		for (g = 0; g < 4; g++) {
 			fill_default_cylinder(&dive->cylinder[g]);
-			dive->cylinder[g].gasmix.o2.permille = (emc_log->o2_percent[g][0] / 256
-				+ emc_log->o2_percent[g][1]) * 10;
-			dive->cylinder[g].gasmix.he.permille = (emc_log->he_percent[g][0] / 256
-				+ emc_log->he_percent[g][1]) * 10;
+			dive->cylinder[g].gasmix.o2.permille =
+				(log[EMC_O2_PERCENT + g * 2] / 256
+				+ log[EMC_O2_PERCENT + g * 2 + 1]) * 10;
+			dive->cylinder[g].gasmix.he.permille =
+				(log[EMC_HE_PERCENT + g * 2] / 256
+				+ log[EMC_HE_PERCENT + g * 2 + 1]) * 10;
 		}
 
-		tm.tm_year = emc_log->year;
-		tm.tm_mon = emc_log->month - 1;
-		tm.tm_mday = emc_log->day;
-		tm.tm_hour = emc_log->hour;
-		tm.tm_min = emc_log->minutes;
-		tm.tm_sec = emc_log->seconds;
+		tm.tm_year = log[EMC_YEAR];
+		tm.tm_mon = log[EMC_MON] - 1;
+		tm.tm_mday = log[EMC_DAY];
+		tm.tm_hour = log[EMC_HOUR];
+		tm.tm_min = log[EMC_MIN];
+		tm.tm_sec = log[EMC_SEC];
 		tm.tm_isdst = -1;
 
 		dive->when = dc->when = utc_mktime(&tm);
-		dive->number = emc_log->number[0] + emc_log->number[1] * 256 + 1;
-		dc->duration.seconds = (emc_log->bt[0] + emc_log->bt[1] * 256) * 60;
-		dc->surfacetime.seconds = (emc_log->sit[0] + emc_log->sit[1] * 256) * 60;
-		dc->maxdepth.mm = (emc_log->max_depth[0] +
-			emc_log->max_depth[1] * 256) / 4 * FEET * 1000;
-		dc->meandepth.mm = (emc_log->avg_depth[0] +
-			emc_log->avg_depth[1] * 256) / 4 * FEET * 1000;
-		dc->watertemp.mkelvin = C_to_mkelvin((emc_log->temp - 32) / 1.8);
+		dive->number = log[EMC_NUMBER] + log[EMC_NUMBER + 1] * 256 + 1;
+		dc->duration.seconds = (log[EMC_BT] + log[EMC_BT + 1] * 256) * 60;
+		dc->surfacetime.seconds = (log[EMC_SIT] + log[EMC_SIT + 1] * 256) * 60;
+		dc->maxdepth.mm = (log[EMC_MAX_DEPTH] +
+			log[EMC_MAX_DEPTH + 1] * 256) / 4 * FEET * 1000;
+		dc->meandepth.mm = (log[EMC_AVG_DEPTH] +
+			log[EMC_AVG_DEPTH + 1] * 256) / 4 * FEET * 1000;
+		dc->watertemp.mkelvin = C_to_mkelvin((log[EMC_MIN_TEMP] - 32) / 1.8);
 		dc->surface_pressure.mbar = ATM / BAR * pow(1 - 0.0000225577
-			* (double) emc_log->altitude * 250 * FEET, 5.25588) * 1000;
-		dc->salinity = 10000 + 150 * emc_log->water_conductivity;
+			* (double) log[EMC_ALTITUDE] * 250 * FEET, 5.25588) * 1000;
+		dc->salinity = 10000 + 150 * (log[EMC_WATER_CONDUCTIVITY] & 0x3);
 
-		SHA1(emc_log->number, 2, (unsigned char *)csum);
+		SHA1(log + EMC_NUMBER, 2, (unsigned char *)csum);
 		dc->diveid = csum[0];
 
-		if (emc_log->max_depth[0] == 0xff && emc_log->max_depth[1] == 0xff)
+		if (log[EMC_MAX_DEPTH] == 0xff && log[EMC_MAX_DEPTH + 1] == 0xff)
 			corrupt_dive = 1;
 
 		break;
diff --git a/cochran.h b/cochran.h
new file mode 100644
index 0000000..7eef92f
--- /dev/null
+++ b/cochran.h
@@ -0,0 +1,45 @@
+// Commander log fields
+#define CMD_SEC					1
+#define CMD_MIN					0
+#define CMD_HOUR				3
+#define CMD_DAY					2
+#define CMD_MON					5
+#define CMD_YEAR				4
+#define CME_START_OFFSET		6		// 4 bytes
+#define CMD_WATER_CONDUCTIVITY	25		// 1 byte, 0=low, 2=high
+#define CMD_START_SGC			42		// 2 bytes
+#define CMD_START_TEMP			45		// 1 byte, F
+#define CMD_START_DEPTH			56		// 2 bytes, /4=ft
+#define CMD_START_PSI			62
+#define CMD_SIT					68		// 2 bytes, minutes
+#define CMD_NUMBER				70		// 2 bytes
+#define CMD_ALTITUDE			73		// 1 byte, /4=Kilofeet
+#define CMD_END_OFFSET			128		// 4 bytes
+#define CMD_MIN_TEMP			153		// 1 byte, F
+#define CMD_BT					166		// 2 bytes, minutes
+#define CMD_MAX_DEPTH			168		// 2 bytes, /4=ft
+#define CMD_AVG_DEPTH			170		// 2 bytes, /4=ft
+#define CMD_O2_PERCENT			210		// 8 bytes, 4 x 2 byte, /256=%
+
+// EMC log fields
+#define EMC_SEC					0
+#define EMC_MIN					1
+#define EMC_HOUR				2
+#define EMC_DAY					3
+#define EMC_MON					4
+#define EMC_YEAR				5
+#define EMC_START_OFFSET		6		// 4 bytes
+#define EMC_WATER_CONDUCTIVITY	24		// 1 byte bits 0:1, 0=low, 2=high
+#define EMC_START_DEPTH			42		// 2 byte, /256=ft
+#define EMC_START_TEMP			55		// 1 byte, F
+#define EMC_SIT					84		// 2 bytes, minutes, LE
+#define EMC_NUMBER				86		// 2 bytes
+#define EMC_ALTITUDE			89		// 1 byte, /4=Kilofeet
+#define EMC_O2_PERCENT			144		// 20 bytes, 10 x 2 bytes, /256=%
+#define EMC_HE_PERCENT			164		// 20 bytes, 10 x 2 bytes, /256=%
+#define EMC_END_OFFSET			256		// 4 bytes
+#define EMC_MIN_TEMP			293		// 1 byte, F
+#define EMC_BT					304		// 2 bytes, minutes
+#define EMC_MAX_DEPTH			306		// 2 bytes, /4=ft
+#define EMC_AVG_DEPTH			310		// 2 bytes, /4=ft
+
diff --git a/cochran_cmdr.h b/cochran_cmdr.h
deleted file mode 100644
index 1c5f938..0000000
--- a/cochran_cmdr.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * subsurface
- *
- * Copyright (C) 2014 John Van Ostrand
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-
-
-struct cochran_cmdr_log_t {
-	// Pre-dive 128 bytes
-	unsigned char minutes, seconds;			// 2 bytes
-	unsigned char day, hour, year, month;	// 4 bytes
-	unsigned char sample_start_offset[4];	// 4 bytes
-	unsigned char start_timestamp[4];		// 4 bytes
-	unsigned char pre_dive_timestamp[4];	// 4 bytes
-	unsigned char unknown1[6];				// 6 bytes
-	unsigned char water_conductivity;		// 1 byte [0=low, 2=high]
-	unsigned char unknown2[5];				// 5 bytes
-//30
-	unsigned char sample_pre_event_offset[4];// 4 bytes
-	unsigned char unknown3[4];				// 4 bytes
-	unsigned char start_battery_voltage[2];	// 2 bytes [/256]
-//40
-	unsigned char unknown4[2]; 				// 2 bytes
-	unsigned char start_sgc[2];				// 2 bytes
-	unsigned char entered_or_computed_po[2];// 2 bytes ???
-	unsigned char unknown5[10];				// 10 bytes
-//56
-	unsigned char start_depth[2];			// 2 byte [/4]
-	unsigned char unknown6[4];				// 3 bytes
-	unsigned char start_psi[2];				// 2 bytes LE
-	unsigned char unknown7[4];				// 4 bytes
-	unsigned char sit[2];					// 2 bytes
-//70
-	unsigned char number[2];				// 2 bytes
-	unsigned char unknown8[1];				// 1 byte
-	unsigned char altitude;					// 1 byte [/4 = kft]
-	unsigned char unknown9[28];				// 27 bytes
-	unsigned char alarm_depth[2];			// 2 bytes
-	unsigned char unknown10[4];				// 5 bytes
-//108
-	unsigned char repetitive_dive;			// 1 byte
-	unsigned char unknown11[3];				// 3 bytes
-	unsigned char start_tissue_nsat[16];	// 16 bytes [/256]
-
-	// Post-dive 128 bytes
-	unsigned char sample_end_offset[4];		// 4 bytes
-	unsigned char unknown12[21];			// 21 bytes
-	unsigned char temp;						// 1 byte
-	unsigned char unknown13[12];			// 12 bytes
-	unsigned char bt[2];					// 2 bytes [minutes]
-//168
-	unsigned char max_depth[2];				// 2 bytes [/4]
-	unsigned char avg_depth[2];				// 2 bytes
-	unsigned char unknown14[38];			// 38 bytes
-//210
-	unsigned char o2_percent[4][2];			// 8 bytes
-	unsigned char unknown15[22];			// 22 bytes
-	unsigned char end_tissue_nsat[16];		// 16 bytes [/256]
-} __attribute__((packed));
-
-struct cochran_cmdr_config1_t {
-	unsigned char unknown1[209];
-	unsigned short int dive_count;
-	unsigned char unknown2[274];
-	unsigned short int serial_num; // @170
-	unsigned char unknown3[24];
-} __attribute__((packed));
diff --git a/cochran_emc.h b/cochran_emc.h
deleted file mode 100644
index 46a56fe..0000000
--- a/cochran_emc.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * subsurface
- *
- * Copyright (C) 2014 John Van Ostrand
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA
- */
-
-// 512 bytes for each dive in the log book
-struct cochran_emc_log_t {
-	// Pre-dive 256 bytes
-	unsigned char seconds, minutes, hour;		// 3 bytes
-	unsigned char day, month, year;				// 3 bytes
-	unsigned char sample_start_offset[4];		// 4 bytes
-	unsigned char start_timestamp[4];			// 4 bytes [secs from jan 1,92]
-	unsigned char pre_dive_timestamp[4];		// 4 bytes [secs from Jan 1,92]
-	unsigned char unknown1[6];					// 6 bytes
-	unsigned char water_conductivity;			// 1 byte  [0 =low, 2-high]
-	unsigned char unknown2[5];					// 5 bytes
-//30
-	unsigned char sample_pre_event_offset[4];	// 4 bytes
-	unsigned char config_bitfield[6];			// 6 bytes
-	unsigned char unknown3[2];					// 2 bytes
-	unsigned char start_depth[2];				// 2 bytes [/256]
-	unsigned char unknown4[2];					// 2 bytes
-	unsigned char start_battery_voltage[2];		// 2 bytes [/256]
-//48
-	unsigned char unknown5[7];					// 7 bytes
-	unsigned char start_temperature;			// 1 byte  [F]
-	unsigned char unknown6[28];					// 28 bytes
-	unsigned char sit[2];						// 2 bytes [minutes]
-	unsigned char number[2];					// 2 bytes
-	unsigned char unknown7[1]; 					// 1 bytes
-	unsigned char altitude;						// 1 byte [/4 = kft]
-	unsigned char start_nofly[2];				// 2 bytes [/256 = hours]
-//92
-	unsigned char unknown8[18]; 				// 18 bytes
-	unsigned char post_dive_sit[2];				// 2 bytes  [seconds]
-	unsigned char po2_set_point[9][2];			// 18 bytes	[/256 = %]
-	unsigned char unknown9[12]; 				// 12 bytes
-	unsigned char po2_alarm[2]; 				// 2 bytes  [/256 = %]
-//144
-	unsigned char o2_percent[10][2];			// 20 bytes	[/256 = %]
-	unsigned char he_percent[10][2];			// 20 bytes	[/256 = %]
-	unsigned char alarm_depth[2];				// 2 bytes
-	unsigned char unknown10[14]; 				// 14 bytes
-	unsigned char conservatism;					// 1 bytes [/256 = fraction]
-	unsigned char unknown11[2];					// 2 bytes
-	unsigned char repetitive_dive;				// 1 byte
-	unsigned char unknown12[12];				// 12 bytes
-	unsigned char start_tissue_nsat[20][2];		// 40 bytes [/256]
-
-	// Post-dive 256 bytes
-	unsigned char sample_end_offset[4];			// 4 bytes
-	unsigned char unknown13[33];				// 33 bytes
-	unsigned char temp;							// 1 byte  [F]
-	unsigned char unknown14[10];				// 10 bytes
-// 48
-	unsigned char bt[2];						// 2 bytes [minutes]
-	unsigned char max_depth[2];					// 2 bytes [/4 = ft]
-	unsigned char unknown15[2];					// 2 bytes
-	unsigned char avg_depth[2];					// 2 bytes [/4 = ft]
-	unsigned char min_ndc[2];					// 2 bytes [minutes]
-	unsigned char min_ndx_bt[2];				// 2 bytes [minutes]
-	unsigned char max_forecast_deco[2];			// 2 bytes [minutes]
-	unsigned char max_forecast_deco_bt[2];		// 2 bytes [minutes]
-//64
-	unsigned char max_ceiling[2];				// 2 bytes [*10 = ft]
-	unsigned char max_ceiling_bt[2];			// 2 bytes [minutes]
-	unsigned char unknown16[10];				// 18 bytes
-	unsigned char max_ascent_rate; 				// 1 byte  [ft/min]
-	unsigned char unknown17[3];					// 3 bytes
-	unsigned char max_ascent_rate_bt[2];		// 2 bytes [seconds]
-//84
-	unsigned char unknown18[54];				// 54 bytes
-//138
-	unsigned char end_battery_voltage[2];		// 2 bytes [/256 = v]
-	unsigned char unknown19[8];					// 8 bytes
-	unsigned char min_temp_bt[2];    			// 2 bytes [seconds]
-//150
-	unsigned char unknown20[22];				// 22 bytes
-//172
-	unsigned char end_nofly[2];					// 2 bytes	[/256 = hours]
-	unsigned char alarm_count[2];				// 2 byte
-	unsigned char actual_deco_time[2];			// 2 bytes [seconds]
-//178
-	unsigned char unknown21[38];				// 38 bytes
-//216
-	unsigned char end_tissue_nsat[20][2];		// 40 bytes [/256 = fraction]
-} __attribute__((packed));
-
-typedef enum cochran_emc_bitfield_config_t {
-	BF_TEMP_DEPENDENT_N2,
-	BF_ASCENT_RATE_BAR_GRAPH,
-	BF_BLEND_2_SWITCHING,
-	BF_ALTITUDE_AS_ONE_ZONE,
-	BF_DECOMPRESSION_TIME_DISPLAY,
-	BF_BLEND_3_SWITCHING,
-	BF_VARIABLE_ASCENT_RATE_ALARM,
-	BF_ASCENT_RATE_RESPONSE,
-	BF_REPETITIVE_DIVE_DEPENDENT_N2,
-	BF_TRAINING_MODE,
-	BF_CONSTANT_MODE_COMPUTATIONS,
-	BF_DISPLAYED_UNITS,
-	BF_AUDIBLE_ALARM,
-	BF_CLOCK,
-	BF_CEILING_DISPLAY_DIV_BY_10,
-	BF_GAS_2_AS_FIRST_GAS,
-	BF_ENABLE_HELIUM_COMPUTATIONS,
-	BF_AUTOMATIC_PO2_FO2_SWITCHING,
-	BF_TOUCH_PROGRAMMING_PO2_FO2_SWITCH,
-} cochran_emc_bitfield_config_t;
-
-
-struct cochran_emc_bitfield_t {
-	cochran_emc_bitfield_config_t config;
-	unsigned char word;
-	unsigned char byte;
-	unsigned char mask;
-	unsigned char shift;
-} cochran_emc_bitfield_t;
-
-static struct cochran_emc_bitfield_t cochran_emc_bits[] = {
-// Word BD
-	{ BF_TEMP_DEPENDENT_N2, 0xBD, 0, 0x40, 6 }, 			// 0=normal, 1=reduced
-	{ BF_ASCENT_RATE_BAR_GRAPH, 0xBD, 0, 0x20, 5 },			// 0=fixed, 1=proportional
-	{ BF_BLEND_2_SWITCHING, 0xBD, 0, 0x04, 2 },			// 0=dis, 1=ena
-	{ BF_ALTITUDE_AS_ONE_ZONE, 0xBD, 0, 0x02, 1},			// 0=off, 1=on
-
-	{ BF_DECOMPRESSION_TIME_DISPLAY, 0xBD, 1, 0xC0, 5},		// 111=both, 011=stop, 001=total
-	{ BF_BLEND_3_SWITCHING, 0xBD, 1, 0x10, 4 },			// 0=dis, 1=ena
-	{ BF_VARIABLE_ASCENT_RATE_ALARM, 0xBD, 1, 0x04, 3},		// 0=off, 1=on
-	{ BF_ASCENT_RATE_RESPONSE, 0xBD, 1, 0x07, 0},
-
-//WORD BE
-	{ BF_REPETITIVE_DIVE_DEPENDENT_N2, 0xBE, 0, 0x80, 7 },		// 0=off, 1=on
-	{ BF_TRAINING_MODE, 0xBE, 0, 0x04, 2 }, 			// 0=off, 1=on
-	{ BF_CONSTANT_MODE_COMPUTATIONS, 0xBE, 0, 0x04, 2 },		// 0=FO2, 1=PO2
-	{ BF_DISPLAYED_UNITS, 0xBE, 0, 0x01, 0 },			// 1=metric, 0=imperial
-
-// WORD BF
-	{ BF_AUDIBLE_ALARM, 0xBF, 0, 0x40, 6 }, 			// 0=on, 1=off ***
-	{ BF_CLOCK, 0xBF, 0, 0x20, 5 },					// 0=off, 1=on
-	{ BF_CEILING_DISPLAY_DIV_BY_10, 0xBF, 0, 0x10, 4 },		// 0=off, 1=on
-	{ BF_GAS_2_AS_FIRST_GAS, 0xBF, 0, 0x02, 1 },			// 0=dis, 1=ena
-	{ BF_ENABLE_HELIUM_COMPUTATIONS, 0xBF, 0, 0x01, 0 },		// 0=dis, 1=ena
-
-	{ BF_AUTOMATIC_PO2_FO2_SWITCHING, 0xBF, 1, 0x04, 2 },		// 0=dis, 1=ena
-	{ BF_TOUCH_PROGRAMMING_PO2_FO2_SWITCH, 0xBF, 1, 0x02, 1 },	// 0=dis, 1=ena
-};
-
-struct cochran_emc_config1_t {
-	unsigned char unknown1[209];
-	unsigned short int dive_count;
-	unsigned char unknown2[274];
-	unsigned short int serial_num;
-	unsigned char unknown3[24];
-} __attribute__((packed));
diff --git a/subsurface.pro b/subsurface.pro
index 53f7f4b..ce7d341 100644
--- a/subsurface.pro
+++ b/subsurface.pro
@@ -21,8 +21,7 @@ QMAKE_CLEAN += $$TARGET
 VERSION = 4.2
 
 HEADERS = \
-	cochran_cmdr.h \
-	cochran_emc.h \
+	cochran.h \
 	color.h \
 	deco.h \
 	device.h \
-- 
1.8.3.1



More information about the subsurface mailing list