-
Notifications
You must be signed in to change notification settings - Fork 105
Add support for the Shearwater Swift GPS #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: Subsurface-DS9
Are you sure you want to change the base?
Add support for the Shearwater Swift GPS #98
Conversation
|
Note that the the whole "single location" thing is somethign that the Garmin works around by just reporting multiple locations as free-hand text: so that the information is at least there in the extra info, and people can see it (even if it doesn't then show up on the map) The right thing to do would be to add a GPS sample, which woudl also solve the issue of dives where you peek up in the middle of the dive to see where the heck the boat is (or where the shore is when you're really lost ;) |
That's indeed one of the options I'm looking into. I have most of the implementation already prepared. @mikeller Maybe wait a bit before merging this PR? There is at least one bug in the Shearwater GPS code reported that I'm still looking into. Apparently in some case the values can also contain 0xFFFFFFFF instead of zero. I suspect there will be some flag to indicate whether GPS data is available. |
|
@torvalds: Yeah, good idea, I can add some extra info items for end location, and potentially more data points like 'location at x min'. @jefdriesen: Thanks for the heads up, will hold off then. I am still waiting for Shearwater to get back to me with the spec for this, last I heard they were swamped with support. 😆 Being able to store the location as part of the sample information would be nice - also seeing that some manufacturers (including Suunto) are working on using inertial data to generate 3D dive profiles. But I suspect it will be tricky to implement this in Subsurface in a way that makes the data format backwards compatible. |
With the new Swift GPS transmitter, the GPS location of the dive entry and exit points are stored in the opening and closing record number 9. At the moment only the entry location is reported because the api only supports a single location. Cherry-picked-by: Michael Keller <[email protected]> Signed-off-by: Michael Keller <[email protected]>
0c678bc to
074b669
Compare
|
I have pushed the extra fixes. This should work fine now, unless there are other special cases that we haven't seen yet. I also haven't received any updates from Shearwater. |
Apparantly the GPS location fields can also contain the magic value 0xFFFFFFFF (or -1 as signed integer) to indicate the absence of a GPS location. Reported-by: Greg McLaughlin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for the Shearwater Swift GPS transmitter, which stores GPS coordinates for dive entry and exit points in opening and closing record number 9. Currently, only the entry location is exposed due to API limitations.
Changes:
- Extended record type constants to support records 8 and 9 for both opening and closing
- Updated NRECORDS constant from 8 to 10 to accommodate the new record types
- Implemented GPS location parsing from opening record 9 with proper validation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return DC_STATUS_UNSUPPORTED; | ||
| latitude = (signed int) array_uint32_be (data + parser->opening[9] + 21); | ||
| longitude = (signed int) array_uint32_be (data + parser->opening[9] + 25); | ||
| if ((latitude == 0 && longitude == 0) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dirkhh: Have you been able to get an updated protocol spec from Shearwater? I'd really like to know if these checks are indeed the way they have specified this - while Null island isn't the world's most popular dive destination, it seems to be loony to take perfectly valid coordinates and use them as sentinel values for 'no location information'...
The same obviously also goes for '-1 island.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still waiting
Good reminder to poke them again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still waiting
Good reminder to poke them again
|
On Tue, 13 Jan 2026 at 17:30, Michael Keller ***@***.***> wrote:
while Null island isn't the world's most popular dive destination, it seems to be loony to take perfectly valid coordinates
No. They aren't valid coordinates. Not for an actual real instrument.
Remember: reality has noise. There is no such thing as "exact GPS
coordinate" in reality. You will not get all zeroes from a real GPS
location, even if you are very close to the Null island. And even if
you do - by random chance - the next coordinates will be something
else. So you're still fine.
And even if you were to get 0,0 as a GPS coordinate, NOBODY CARES.
It's really not an interesting location for diving.
Don't confuse theory with reality.
So the *real* objection should be to the insanity that is using
floating point here. A few lines down, we have this complete garbage:
location->latitude = latitude / 100000.0;
location->longitude = longitude / 100000.0;
PLEASE don't do the complete garbage that Jef has decided on. Floating
point for data IS NOT OK.
There is a real reason why all core types in subsurface are based on
integral fractions. We do depths in mm, we do pressures in millibars,
and we do locations in microdegrees.
A microdegree has well-defined precision - and is more than
sufficient. In contrast, floating point does *not* have well-defined
precision, and the numbers are fundamentally more precise around zero
than around +-180 degrees.
I have seen way too many garbage dive logs that do not understand
floating point, and then you have "fun" things like we see in the uddf
test-files:
<depth>9.859999999999999</depth>
because somebody really didn't understand floating point.
And I guarantee that "didn't understand floating point" is about 99%
of all programmers. Don't do it.
(Just do "git grep 99999" and cry. This kind of garbage is everywhere)
Yes, this is a pet peeve of mine. Integer fractions with proper type
safety (by enclosing them in structures) and conversion functions
(thanks to the type safety) are just superior.
Floating point is for "close enough and I don't care, and I don't
understand". Use it for visualization - not for the underlying hard
data!
Linus
|
Ok, point taken, my concern is more of a theoretical nature than practical. But at the end of the day I still think it is preferable to use actual specs as the basis for an implementation over using inferred information that is based on a limited set of data.
This point can equally be made about ANY other point that the microdegree format used in Subsurface can encode - if we are worried that we are storing too much information, we should address this by reducing the resolution, not by throwing out individual data points based on a hunch that they might have a special meaning.
I do agree that using floats for coordinates is not a good approach. But based on the discussion in subsurface/subsurface#4668 (comment) we've agreed that accepting that this is the way that libdivecomputer has implemented this and getting support for location information from dive computer that support this (or will do so) is preferrable to rewriting this entire thing in our 'not-a-fork' of libdivecomputer, which will create more work for us now and into the future.
Yeah I can see your point - and I do agree that 99% of programmers don't understand floating point when they try to use it for storing or transmitting measurements. |
With the new Swift GPS transmitter, the GPS location of the dive entry
and exit points are stored in the opening and closing record number 9.
At the moment only the entry location is reported because the api only
supports a single location.
Cherry-picked-by: Michael Keller [email protected]
Signed-off-by: Michael Keller [email protected]