Changes to dive sample structure

Dirk Hohndel dirk at hohndel.org
Tue Apr 22 07:23:48 PDT 2014


Hi Willem

A few questions...

On Tue, 2014-04-22 at 12:05 +0200, Willem Ferguson wrote:
> Here are suggested additions to the existing sample structure in order 
> to accommodate dive logs from rebreather systems.
> 
> struct sample {
> 	duration_t time;
> 	depth_t depth;
> 	temperature_t temperature;
> 	pressure_t cylinderpressure;
> 	int sensor;   /* pressure of primary cylinder */
>          int pdiluent; /* pressure of diluent cylinder in CCR dive log*/

so that would be 
	pressure_t pdiluent;
:-)

> 	duration_t ndl;
> 	duration_t stoptime;
> 	depth_t stopdepth;
> 	bool in_deco;
> 	int cns;
> 	int po2		// O2 reading from 1st O2 sensor in CCR divelog
> 	int o2sensor2;  // O2 reading from 2nd O2 sensor in CCR divelog
> 	int o2sensor3;  // O2 reading from 3rd O2 sensor in CCR divelog

IIRC the readings from these sensors will be between 0.10 (because if
it's below that, you won't come back to download the data), and 2.5
(because above that, you won't come back to download the data, either).
What's the resolution? 0.01? So this would easily fit in 

	uint8_t o2sensor[3];

> 	int ccrsetpoint;	// CCR O2 setpoint

and then we could nicely pack the setpoint into it as well.

struct __attribute__((__packed__)) {
	uint8_t setpoint;
	uint8_t o2sensor[3];
}

and instead of 4 32 bit values we added just one 32 bit value.
Or, if you are worried about higher resolution (unlikely, but possible)
or people who want to do some hyper saturation shit (hey, they dive a
rebreather, we KNOW that they are crazy and/or suicidal) and who want
pO₂ > 2.55... pack 16bit integers with mbar resolution. That gives you
0.001 -> 65.535 as range for your pO₂ - and still only adds 64 bit.

> 	int heartbeat;
> 	int bearing;
> };
> 
> The above changes add four integers (i.e. 16 bytes of int32) to the
> sample structure in order to accomodate rebreather dive logs. These are
> necessitated because of the large amount of information logged by
> rebreather dive computers and which most rebreather divers would
> consider as pretty important because it allows evaluation of the oxygen
> sensors as well as the efficiency of the oxygen management system
> during a dive. There is talk that some of the new rebreather systems
> will include an inline CO2 sensor as well.

Yep, makes sense.

> The concern is about bloat in the size of dive logs if several fields
> are added to the existing sample structure. I assume that the int
> variables in the structure are int32. There is clearly no need for a
> signed integer. Would it be helpful at all if the int variables are
> changed to uint16? That would decrease the size of the above structure
> by 18 bytes.

I think making the partial pressures uint8_t values gives us the range
and resolution we need (and I have yet to see a dive computer that gives
us more) and would nicely balance bloat and functionality.

> I have a suspicion that such a change (to uint16) would have repercussions in many places within the existing code base.

cns certainly doesn't need to be an int :-)

/D



More information about the subsurface mailing list