[subsurface] Display "air" for imported dives with 21% O2 (#95)
torvalds at linux-foundation.org
Fri Dec 30 13:06:28 PST 2011
On Fri, Dec 30, 2011 at 4:12 AM, henrik242
<reply+i-2688455-75a133f3b0d4677cc537f5758893e037dda6f9a7-1024025 at reply.github.com>
> Dives imported from my Suunto Zoop are saved with a cylinder with o2="21.0%".
> These were displayed as "21" and not "air" in the divelist.
So I think this patch is wrong.
It fixes the divelist output, but it does so by hiding the fact that
some dives clearly have "o2.permille=210" rather than just zero in the
So some import function has saved air as 21 percent nitrox, and the
internal data structures then use that. But in subsurface we *should*
mark air by not having a number at all (exactly due to the confusion
about 20.9 and 21% etc).
So in this case, the "209" in get_dive_gas() should just match the
earlier 209 in the same function (ie it *should* come from the
original zero value).
So something has imported a gasmix without then calling
"sanitize_cylinder_info()" on it - that *should* have verified all the
percentages and turned 20.9-21% O2 into "air".
I *think* that the correct thing to do would be to just make
"fixup_dive()" do that cylinder sanitize operation directly, instead
of forcing the callers to do it. Right now it looks to me like only
reading an xml file will fix up cylinder info (so importing, then
saving and re-loading would fix the "air" issue), and that means that
an "import" looks different than a "read xml file". Which is
It also means, for example, that we don't seem to currently do the
"match with standard cylinder names" at import time - again you'd have
to save and then re-load the xml file to get that. Of course, you
don't see that with your Suunto, since the dive computer doesn't save
enough information to match with a standard cylinder, but it's another
example of the same issue - currently reading from an xml file does a
few extra cleanups that aren't done anywhere else.
Here's a suggested replacement patch. It looks big, but it's literally
just moving the gas sanitizing from "dive_end()" (in the XML parsing)
to "fixup_dive()" (which is called when recording the dive and making
it available). So there's no new code, it's just moving things around.
Does the attached patch fix the import for you?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 6857 bytes
Desc: not available
More information about the subsurface