understanding the sensor values in our samples

Dirk Hohndel dirk at hohndel.org
Thu Apr 28 10:34:34 PDT 2022



> On Apr 28, 2022, at 10:30 AM, Linus Torvalds <torvalds at linux-foundation.org> wrote:
> 
> On Thu, Apr 28, 2022 at 9:38 AM Dirk Hohndel <dirk at hohndel.org> wrote:
>> 
>> except that's not what it does.
>> If you have four cylinders, because that's what your dive computer provides
>> in the download, then it sets index 0 to the cylinder that is in use, and index 1
>> stays 1.
>> Which then the code I mentioned interprets as "oh, cylinder 1 is in use"
> 
> Hmm. That "index[0] = 0" and "index[1] = 1" (if you have two or more
> cylinders) is kind of very much intentional.
> 
> In fact, we should probably fill in all the other 'index[]' entries
> too, but we never did, because dive computers that support more than
> two sensors will also give the actual explicit sensor number when
> downloading, so all this "implicit sensor number" is just garbage for
> the legacy cases.
> 
> But that "index[1] = 1" shouldn't mean "cylinder 1 is in use" - unless
> you then actually have pressure samples for cylinder 1 (in which case
> it *is* in use, of course).
> 
> So I think *that* is the bug here, not the two lines you quoted.

Yep - my statement was based on an incorrect understanding of how we
are using the information in that array.

> cylinder_renumber() getting this case wrong - now THAT I can most
> definitely believe.
> 
> I wonder if the issue is here (in dc_cylinder_renumber()):
> 
>        /* If the initial cylinder of a dive was remapped, add a gas
> change event to that cylinder */
>        if (mapping[0] > 0)
>                add_initial_gaschange(dive, dc, 0, mapping[0]);
> 
> where we blindly add that initial gaschange simply because we go
> "we've remapped the first cylinder, so now we need to add that gas
> change" - but that is only valid if that first cylinder *was* our
> initial gas to begin with.
> 
> Can you send me the test-case so that I can follow along?

Yep, will do off list.

/D


More information about the subsurface mailing list