RFC: New api for gas changes

Linus Torvalds torvalds at linux-foundation.org
Wed Jun 3 08:41:38 PDT 2015


On Fri, May 22, 2015 at 7:34 AM, Jef Driesen <jef at libdivecomputer.org> wrote:
>
> I have been working on a new api for gas changes. The idea is that old gas
> change events (SAMPLE_EVENT_GASCHANGE and SAMPLE_EVENT_GASCHANGE2) will be
> replaced with a new DC_SAMPLE_GASMIX sample. The corresponding sample data
> is an integer with the index of the gas mix.

Side note: did you consider just doing both gasmix and index? Document
that either (or both) will be set, and make "index=-1" be the "I don't
have an index".

We end up doing that in subsurface anyway. Now, it's mostly
historical: because we had the gasmix, that's what we want in some
places, but then we _also_ want the index for disambiguation.

But it turns out having both actually has some advantages, even though
it sounds redundant.

For example, on some dive computers, you might not *get* an index
(because the dive computer fundamentally just reports O2 percentage in
the event). So then it would be better to say "I don't know the index"
than basically make up a possibly ambiguous cylinder.

And I think some others (Petrel?) allow you to change the mix during
the dive for a special cylinder (perhaps you set your mixes wrong, or
perhaps you're breathing a buddy gas). Sure, you can give the index
for the special cylinder, but what happens if the user changed the
gasmix twice? I'm not sure what the dive computer reports, but from a
abstraction standpoint it would be good to give both index and mix -
at least there's no dropped information, even if it might also confuse
some user of libdivecomputer.

                 Linus


More information about the devel mailing list