Changeset fe5f15b in subsurface


Ignore:
Timestamp:
Jan 16, 2017, 5:45:00 PM (5 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
e1ee577
Parents:
73641c4e
git-author:
Linus Torvalds <torvalds@…> (01/03/17 15:18:03)
git-committer:
Dirk Hohndel <dirk@…> (01/16/17 17:45:00)
Message:

Add support for libdivecomputer using DC_SAMPLE_GASMIX

New libdivecomputer versions use DC_SAMPLE_GASMIX to indicate a gas
change (which contains the cylinder index we're changing to) rather than
SAMPLE_EVENT_GASCHANGE*.

Unlike the old GASCHANGE model, and despite the name, DC_SAMPLE_GASMIX
does not actually say what the mix is, it only specifies a cylinder
index. We had already extended SAMPLE_EVENT_GASCHANGE2 to have the
cylinder index in the otherwise unused "flags" field, so this is not all
that different from what we used to do.

And subsurface internally already had the logic that "if we know what
the cylinder index is, take the gas mix from the cylinder data", so
we've already been able to transparently use _either_ the actual gas mix
or the cylinder index to show the event.

But we do want to make it an event rather than some sample data, because
we want to show it as such in the profile. But because we are happy
with just the cylinder index, we'll just translate the DC_SAMPLE_GASMIX
thing to the SAMPLE_EVENT_GASCHANGE2 event, and nothing really changes
for subsurface.

libdivecomputer has made other changes, like indicating the initial
cylinder index with an early DC_SAMPLE_GASMIX report, but we've seen
that before too (in the form of early SAMPLE_EVENT_GASCHANGE events), so
that doesn't really end up changing anything for us either.

HOWEVER, one thing that is worth noticing: do *not* apply this patch and
then use an old libdivecomputer library that sends both the
DC_SAMPLE_GASMIX samples _and_ the deprecated SAMPLE_EVENT_GASCHANGE
events. It will all *work*, but since subsurface will take either,
you'll then get duplicate gas mix events.

It's not like that is in any way fatal, but it might be a bit confusing.

Signed-off-by: Linus Torvalds <torvalds@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/libdivecomputer.c

    r983561b rfe5f15b  
    252252}
    253253
     254static void handle_gasmix(struct divecomputer *dc, struct sample *sample, int idx)
     255{
     256        if (idx < 0 || idx >= MAX_CYLINDERS)
     257                return;
     258        add_event(dc, sample->time.seconds, SAMPLE_EVENT_GASCHANGE2, idx+1, 0, "gaschange");
     259        current_gas_index = idx;
     260}
     261
    254262void
    255263sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
     
    307315                sample->sensor = value.pressure.tank;
    308316                sample->cylinderpressure.mbar = rint(value.pressure.value * 1000);
     317                break;
     318        case DC_SAMPLE_GASMIX:
     319                handle_gasmix(dc, sample, value.gasmix);
    309320                break;
    310321        case DC_SAMPLE_TEMPERATURE:
Note: See TracChangeset for help on using the changeset viewer.