Repository navigation
Conversation
Garmin FIT logs can mark each tank-pod sensor's SENSOR_PROFILE field
78 ("used for SAC calculations?") to say whether the dive computer
counts that tank toward the diver's own gas consumption. The parser
decoded the field into garmin_sensor.sensor_used_for_gas_rate but
never exposed it, and DC_FIELD_TANK was not populated for Garmin at
all.
The field's meaning is confirmed by Garmin's own Descent T1/T2
manuals (the transceiver "SAC/RMV/ATR" setting) and independently by
the public FIT file attached to subsurface#4465: field 78 is 1 on the
reporter's own tank and 0 on a second, watched sensor that carries a
different user-assigned transmitter name, consistent with both
pressure traces. This is a single dive on Mk2i/Mk3i-era firmware and
has not been verified across other Garmin dive computer models.
Add DC_TANK_USAGE_INCLUDED/DC_TANK_USAGE_EXCLUDED to dc_tank_usage_t,
documented in terms of gas consumption rather than ownership, with
DC_TANK_USAGE_NONE kept as the 0/default value.
Storage has to be tri-state: the field-decoding machinery drops
absent/invalid (0xff) values before the handler runs, and the sensor
struct is memset to zero per dive, so a raw 0 is ambiguous between
"device said not counted" and "device said nothing". Track a
separate sensor_used_for_gas_rate_valid flag so a log that omits
field 78 reports DC_TANK_USAGE_NONE, never EXCLUDED. The per-tank
index matches the one already used for DC_SAMPLE_PRESSURE (both walk
garmin->dive.sensor[]). Volume/type/workpressure are left at their
defaults; populating them from TANK_SUMMARY is a separate concern.
Also make field-cache.c's generic DC_FIELD_TANK case set usage from
the cache and explicitly default beginpressure/endpressure to 0, so a
cache-backed backend can never return stale caller memory for those
members. No other backend currently reaches this generic path for
DC_FIELD_TANK without first overriding usage/pressures itself, so
this does not change their behaviour.
Signed-off-by: Michael Keller <github@ike.ch>
| DC_TANK_USAGE_INCLUDED, /* The dive computer counts this tank towards | ||
| the diver's own gas consumption. */ | ||
| DC_TANK_USAGE_EXCLUDED, /* The dive computer does not count this tank | ||
| towards the diver's own gas consumption | ||
| (for example a buddy's or a stage/deco |
There was a problem hiding this comment.
Good catch, thank you. examples/output_xml.c's tank-reporting block prints tank.usage (a dc_tank_usage_t) through the array built for the unrelated dc_usage_t gas-mix mapping, {"none", "oxygen", "diluent", "sidemount"}, so DC_TANK_USAGE_INCLUDED would print as "diluent" and DC_TANK_USAGE_EXCLUDED as "sidemount".
This will be fixed by giving the tank-reporting block its own mapping, {"none", "sidemount", "included", "excluded"}, matching dc_tank_usage_t's actual enumerator order, without touching the separate gas-mix block.
There was a problem hiding this comment.
This has been fixed in commit 590d585 ("examples: fix tank usage XML labels to match dc_tank_usage_t"), which is already part of this PR. The tank-reporting block now has its own usage[] array, {"none", "sidemount", "included", "excluded"}, matching dc_tank_usage_t's actual enumerator order, and no longer reuses the unrelated gas-mix dc_usage_t mapping.
The tank-reporting block in output_xml.c reused the gas-mix usage[]
array ({"none", "oxygen", "diluent", "sidemount"}), which maps
dc_usage_t (NONE/OXYGEN/DILUENT/OPEN_CIRCUIT). dc_tank_usage_t has a
different enumerator order (NONE/SIDEMOUNT/INCLUDED/EXCLUDED), so a
tank with usage DC_TANK_USAGE_SIDEMOUNT was printed as <usage>oxygen</usage>,
and DC_TANK_USAGE_INCLUDED/EXCLUDED had no matching label at all.
Add a tank-specific usage[] array distinct from the gas-mix one, so
the XML output names tank usage correctly. The gas-mix block's own
dc_usage_t mapping is unchanged.
Signed-off-by: Michael Keller <github@ike.ch>

Garmin FIT logs can mark each tank-pod sensor's SENSOR_PROFILE field
78 ("used for SAC calculations?") to say whether the dive computer
counts that tank toward the diver's own gas consumption. The parser
decoded the field into garmin_sensor.sensor_used_for_gas_rate but
never exposed it, and DC_FIELD_TANK was not populated for Garmin at
all.
The field's meaning is confirmed by Garmin's own Descent T1/T2
manuals (the transceiver "SAC/RMV/ATR" setting) and independently by
the public FIT file attached to subsurface#4465: field 78 is 1 on the
reporter's own tank and 0 on a second, watched sensor that carries a
different user-assigned transmitter name, consistent with both
pressure traces. This is a single dive on Mk2i/Mk3i-era firmware and
has not been verified across other Garmin dive computer models.
Add DC_TANK_USAGE_INCLUDED/DC_TANK_USAGE_EXCLUDED to dc_tank_usage_t,
documented in terms of gas consumption rather than ownership, with
DC_TANK_USAGE_NONE kept as the 0/default value.
Storage has to be tri-state: the field-decoding machinery drops
absent/invalid (0xff) values before the handler runs, and the sensor
struct is memset to zero per dive, so a raw 0 is ambiguous between
"device said not counted" and "device said nothing". Track a
separate sensor_used_for_gas_rate_valid flag so a log that omits
field 78 reports DC_TANK_USAGE_NONE, never EXCLUDED. The per-tank
index matches the one already used for DC_SAMPLE_PRESSURE (both walk
garmin->dive.sensor[]). Volume/type/workpressure are left at their
defaults; populating them from TANK_SUMMARY is a separate concern.
Also make field-cache.c's generic DC_FIELD_TANK case set usage from
the cache and explicitly default beginpressure/endpressure to 0, so a
cache-backed backend can never return stale caller memory for those
members. No other backend currently reaches this generic path for
DC_FIELD_TANK without first overriding usage/pressures itself, so
this does not change their behaviour.
Adds
DC_TANK_USAGE_INCLUDEDandDC_TANK_USAGE_EXCLUDEDfor Garmin tank usage reporting and cache-backed tank fields. XML output now maps tank usage values tonone,sidemount,included, andexcluded.