1781 Commits

Author SHA1 Message Date
Dirk Hohndel
7d26fb6a13 Add BLE transport for McLean Extreme
As suggested by Linus.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-15 13:37:18 -07:00
Linus Torvalds
2e63eaec16 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Pull McLean Extreme fix from Jef Driesen.

The McLean Extreme sample interval was wrong, causing imported dives to
appear twice as long as long as they should.

* git://github.com/libdivecomputer/libdivecomputer:
  Fix the sample interval
2020-09-15 10:39:06 -07:00
Jef Driesen
2909863573 Fix the sample interval
The McLean Extreme records a sample every 10 seconds instead of every 20
seconds. This resulted in dive durations that were twice as long as
expected.

Reported-by: David Carron <david_de_carron@hotmail.com>
2020-09-15 15:06:12 +02:00
Linus Torvalds
39dc77d669 Shearwater Teric: remove our local support for the TAG INFO_EVENT
This mostly reverts commit cb7f47b ("Shearwater Teric: add support for
the TAG INFO_EVENT") because upstream libdivecomputer now does this
natively as of commit 3e89e1b ("Add support for parsing info events").

Also, the way this had been done, it looks like it had basically
disabled the support for LOG_RECORD_FREEDIVE_SAMPLE, although nobody
seems to have ever complained, so presumably there aren't a lot of
freedivers using Shearwater dive computers and subsurface.

With this, our main differences with Jef are just the string interface
code, and the fact that we still stop parsing at LOG_RECORD_FINAL.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-09-12 12:22:50 -07:00
Linus Torvalds
d6153a5a07 Merge branch 'Subsurface-DS9' of github.com:Subsurface-divelog/libdc into Subsurface-DS9
Merge Dirk's Peregrine support with Jef's.

Jef had some extra logic, and otherwise the same, so this is just a
history merge with no content difference.

* 'Subsurface-DS9' of github.com:Subsurface-divelog/libdc:
  Add basic detection for Shearwater Peregrine
2020-09-12 12:00:37 -07:00
Linus Torvalds
f33814c13c Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge upstrean libdivecomputer updates from Jef Driesen:

 - a different way to work around the windows 'instance' craziness

 - minor updates to the Shearwater parser

* git://github.com/libdivecomputer/libdivecomputer:
  Add support for parsing info events
  Add support for the Shearwater Peregrine
  Fix a conflict with the Windows header files
  Add a missing parameter for the USB HID filter
2020-09-12 11:55:52 -07:00
Dirk Hohndel
ad566ab04f Add basic detection for Shearwater Peregrine
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-21 16:11:53 -07:00
Jef Driesen
3e89e1b871 Add support for parsing info events 2020-08-22 00:27:11 +02:00
Jef Driesen
e2ecd96daa Add support for the Shearwater Peregrine 2020-08-22 00:05:32 +02:00
Jef Driesen
7a4c5e919f Fix a conflict with the Windows header files
In one of the Windows system header files, an "interface" macro is
defined as:

  #define interface struct

This results in some very strange build errors when also including the
descriptor-private.h header file. That's because the dc_usb_params_t
struct has a member field named "interface":

  typedef struct dc_usb_params_t {
      unsigned int interface;
      unsigned char endpoint_in;
      unsigned char endpoint_out;
  } dc_usb_params_t;

As a workaround, define the WIN32_LEAN_AND_MEAN macro before including
the windows.h header file. This excludes some less common Windows API
declarations, including the above one.
2020-08-21 23:56:52 +02:00
Jef Driesen
51b1ae925c Add a missing parameter for the USB HID filter
In commit 57f0ce6d7902117cfc4d0d6b401b516fc93ca488, an extra parameter
was added to the dc_descriptor_filter() function. But I only updated the
libusb code path and forgot to do the same for the hidapi variant.
2020-08-21 17:57:47 +02:00
Linus Torvalds
1df0e13cc4 Fix for absolutely wonderful Windows feature
It turns out that Windows is more of a PoC than I ever imagined.  The
system headers will have something like this in it:

  #define __STRUCT__ struct
  #define interface __STRUCT__

which means that using the identifier "interface" will result in
completely indecipherable error messages from a Windows compiler.

That's some truly broken stinking garbage.  It's not like "interface" is
even a bad identifier.

Let's just #undef this crazy feature.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-08-20 14:06:46 -07:00
Linus Torvalds
378b9c1aec Fix HIDAPI breakage
When Jef added a filter parameter in commit 57f0ce6 ("Add support for
filter parameters") he didn't do the HIDAPI case, because who uses
HIDAPI?

Windows and OS X, it would seem.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-08-20 13:28:28 -07:00
Linus Torvalds
3c1e763a47 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge upstream changes by Jef Driesen:

 - add support for Liquivision dive computers

 - add support for the Aqualung i470TC

 - extract out Atomic Aquatics Cobalt USB support as a iostream

 - misc fixes

* git://github.com/libdivecomputer/libdivecomputer:
  Fix the OSTC4 firmware upgrade
  Handle a negative number of bytes as an error
  Update the example application
  Use the new USB transport for the Atomic Aquatics Cobalt
  Add an I/O implementation for USB communication
  Add support for filter parameters
  Disable direct access to the filter function
  Increase the receive timeout to 5 seconds
  Fix the McLean Extreme bluetooth name
  Add support for Liquivision dive computers
  Add support for the Aqualung i470TC
2020-08-20 12:36:38 -07:00
Jef Driesen
9dace57814 Fix the OSTC4 firmware upgrade
Commit d1b865d192afc9efde337b5cff8a239366f15565 breaks the OSTC4
firmware upgrade because the OSTC4 expects to receive the service init
command and the service key all at once, before sending any response.

The hwOS firmware still reads the service init command one byte at a
time, and sends the echo immediately after each byte. But in the
meantime, the hwos firmware has also been optimized. The processing time
for an incoming byte is now always faster then the time it takes for the
next byte to physically arrive via the serial line between the USB/BT
chip and the processor. Thus, even without any buffering, sending all
bytes at once should no longer be a problem.

This partially reverts commit d1b865d192afc9efde337b5cff8a239366f15565.

Reported-by: Anton Lundin <glance@acc.umu.se>
Suggested-by: Ralph Lembcke <mail@ralph-lembcke.de>
2020-08-20 15:29:15 +02:00
Jef Driesen
c77551b366 Handle a negative number of bytes as an error
There is no reason for libusb to ever return a negative number of bytes,
but due to the use of a signed integer, it's technically possible. And
because libdivecomputer returns an unsigned integer, such a negative
number would be reported as a very large size.
2020-08-11 15:22:31 +02:00
Jef Driesen
33a20bd2b8 Merge branch 'iostream-usb' 2020-08-11 15:22:07 +02:00
Jef Driesen
5380b247af Update the example application
The application is now responsible for setting up the USB based I/O
stream.
2020-08-11 15:16:36 +02:00
Jef Driesen
c72dc4aa73 Use the new USB transport for the Atomic Aquatics Cobalt
Replace the hardcoded libusb based code with the new USB I/O transport.
This enables the use of a custom I/O on platforms where libusb is not
available.
2020-08-11 15:16:36 +02:00
Jef Driesen
c84bbd93a3 Add an I/O implementation for USB communication
The USB communication is now also implemented as an I/O stream
transport. Unlike most I/O devices, USB communication supports multiple
interfaces and endpoints. This requires some some special care:

In the general case, autodetection isn't really possible without
additional knowledge. Hence the need for the filter parameters to pass
this kind of information.

The implementation assumes two bulk endpoints for the standard
read/write interface. Communication with the control endpoint is
supported through the new DC_IOCTL_USB_CONTROL_{READ,WRITE} ioctl's.
2020-08-11 15:16:36 +02:00
Jef Driesen
57f0ce6d79 Add support for filter parameters
The filter parameter provides a mechanism to pass some additional
information, needed to configure the I/O stream, back to the caller.
2020-08-03 11:51:59 +02:00
Jef Driesen
edacbb2f13 Disable direct access to the filter function
Replace the small helper function to retrieve the function pointer and
then call the function, with another helper function to call the filter
function directly. This way the function pointer doesn't need to be
exposed at all.
2020-08-03 11:51:59 +02:00
Jef Driesen
6986840c0d Increase the receive timeout to 5 seconds
When the fingerprint feature isn't used (or with a timestamp of zero),
the response to the SIZE (0xC6) and DATA (0xC4) commands is received
almost instantly:

    [0.302704] W: C60000000010270000
    [0.366727] R: DCF90F00
    [0.367829] W: C40000000010270000
    [0.394812] R: E0F90F00

But when the fingerprint feature is used (with a non-zero timestamp),
there is a noticable delay:

    [0.341218] W: C64CEB204D10270000
    [1.927905] R: FE0B0000
    [1.931610] W: C44CEB204D10270000
    [5.092081] R: 020C0000

In this particular case, the total amount of dive data was close to 1M
bytes, which pushed the delay over the 3 second timeout, and caused the
download to fail. Increasing the timeout to 5 seconds fixed the problem.

The most likely explanation is that the dive computer needs to scan its
internal logbook to determine which dives and how many bytes to send.
Because that involves reading relative slow flash memory, this can take
up to a few seconds, especially if there are many dives present.

The duration of the delay also depends on the value of the fingerprint
timestamp: the less dives we try to download, the longer the delay! I
suspect that's because the most recent dives are located near the end of
the logbook. Hence, the less dives we request, the more dives the dive
computer needs to skip.

Below are some timings for downloading espectively 792410, 531856 and
270850 bytes from the same dive computer, but with a different
fingerprint value:

    [0.216305] W: C6F8D5C84510270000
    [0.373511] R: 56170C00
    [0.378929] W: C4F8D5C84510270000
    [0.661388] R: 5A170C00

    [0.236246] W: C620D80F4810270000
    [0.559608] R: 8C1D0800
    [0.563755] W: C420D80F4810270000
    [1.171631] R: 901D0800

    [0.246193] W: C654E6434A10270000
    [0.826365] R: FE210400
    [0.831760] W: C454E6434A10270000
    [1.974351] R: 02220400
2020-08-03 11:48:33 +02:00
Jef Driesen
cdd618e683 Fix the McLean Extreme bluetooth name 2020-07-26 17:27:49 +02:00
Jef Driesen
71a149d776 Add support for Liquivision dive computers 2020-07-09 17:02:32 +02:00
Linus Torvalds
6935fe717a Merge branch 'Oceans-S1' into Subsurface-DS9
Add initial support for the Oceans S1.

This expands a bit on the generic functions for the field-cache code,
and uses that to then add a fairly minimal Oceans S1 downloader.

And while it's minimal, it downloads about everything the S1 offers,
which is mainly just depth and temperature.

There are a few fields that it currently doesn't use, notably the
events and NDL information that the dive computer presumably reports in
the auxiliary data that comes in the sample, but without documentation
and more testing I'm not comfortable parsing that.

There's also some "current dive computer state" that isn't imported,
like the battery status.  I know how to read it, but it's not per-dive
data that could be added as extra fields: it's literally just the
current dive computer battery state at the time of the download.

The Oceans team said they'll provide more information about the
download, so this might be expanded in the future, but it seems fairly
usable even in this form.

Thanks to Dhaval Giani for sending me his Oceans S1 as a loaner, and to
Seth Garrison for doing the initial BLE packet dumps that made me think
it was fairly easily doable.

* Oceans-S1:
  Oceans S1: polish up the downloading logic for usability
  Oceans S1: actually download all dives and parse them
  Oceans S1: fill out core download protocol details
  Oceans S1: start filling in protocol details
  Oceans S1: start documenting the download format and first packets
  Add skeleton for Oceans S1 downloader
  Add generic dc_field_get() helper
2020-06-25 11:33:12 -07:00
Linus Torvalds
6b22340ddc Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge upstream libdivecomputer updates from Jef Driesen:

 - Jef merged the EON Steel dive sorting fix we had in our branch: one
   less difference to upstream

 - Jef merged the McLean Extreme support with some updates and cleanups,
   this just takes all his changes.

 - manual pages for iostream

 - various minor fixes and updates from Jef

* git://github.com/libdivecomputer/libdivecomputer:
  Update the gitignore file
  Update the man pages for the new iostream functions
  Purge the serial port buffer during initialization
  Add support for the McLean Extreme
  Suunto Eon Steel: sort the dive list properly
  Remove the salinity compensation
  Fix the hwOS ppO2 bug for firmware v3.08
2020-06-25 11:24:00 -07:00
Linus Torvalds
8d17c3c01c Oceans S1: polish up the downloading logic for usability
This adds a few finishing touches to actually download dives in the
expected order (newest first), which fixes the handling of already
downloaded dives.

It also adds the fingerprinting code to optimize the downloading a bit.

Finally, it handles cancellation in the middle.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-25 10:40:41 -07:00
Linus Torvalds
da8ae52b50 Oceans S1: actually download all dives and parse them
This isn't perfect - we don't do the whole dive fingerprint etc, so
right now it always downloads all dives.

To make matters worse, it downloads dives oldest first, which then
confuses the subsurface downloader that expects newest first.

So there's stuff to clean up, but the basic profile data is all there.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-24 17:09:34 -07:00
Linus Torvalds
91658dd167 Oceans S1: fill out core download protocol details
All of the Oceans S1 protocol seems to be basically ASCII data, but the
bigger chunks of data (the dive list, and the actual dive profiles) are
chunked in 512-byte pieces with sequence numbers and what looks like
some checksum.

This doesn't check the checksum yet, but the basic "download data" seems
to work.

Note that the code doesn't actually _parse_ said data yet, nor create an
actual dive list.  So this is very much only very incremental progress,
but this seems to have been the nastiest part of the actual protocol.

Knock wood.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-24 14:18:57 -07:00
Linus Torvalds
ae58a66d9a Oceans S1: start filling in protocol details
This does the time sync command, which is particularly simple.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-23 15:45:27 -07:00
Linus Torvalds
7018206f56 Oceans S1: start documenting the download format and first packets
The communication seems to be mainly ASCII strings, with the main
complexity probably being that the Nordic Semi UART has some side
channel for switching between line-buffered and "bulk data" modes.

That part might end up being painful and needing more interfaces to the
Subsurface BLE code.

We'll likely need to add more special BLE code.  The Bluetooth SIG
really is a horrible disgrace.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-23 14:28:44 -07:00
Linus Torvalds
d58b8f6928 Add skeleton for Oceans S1 downloader
This does nothing, but fills in all the basic boiler plate code and data
structures.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-23 13:28:10 -07:00
Linus Torvalds
e9129ff45a Add generic dc_field_get() helper
This generic helper just gets everything from the field cache.

Dive computers can do their own things for any field they handle
differently, and then at the end fall back to this for all of the common
cases that are purely described by the field cache structure.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-22 14:56:55 -07:00
Jef Driesen
91acd9bb2d Add support for the Aqualung i470TC 2020-06-19 11:47:46 +02:00
Vincent Hagen
c065a78402 Update the gitignore file 2020-06-15 11:42:22 +02:00
Vincent Hagen
21742bd2ec Update the man pages for the new iostream functions
- Added missing man pages for the new functions.
 - Updated the main libdivecomputer man page to reflect the new flow.
 - Fixed minor typos in the dc_parser_get_field and
   dc_parser_samples_foreach functions.
2020-06-15 11:36:26 +02:00
Jef Driesen
85074dba40 Purge the serial port buffer during initialization 2020-06-08 13:45:43 +02:00
David Carron
8d35ee6978 Add support for the McLean Extreme 2020-06-08 13:45:43 +02:00
Linus Torvalds
9e6035f98a Suunto Eon Steel: sort the dive list properly
Instead of assuming that the dive list is presented in a sorted circular
list, sort it properly alphabetically (which also ends up being a
numerical sort for the HEX ascii dive names).

The "search for most recent dive, then splice the list around" case
doesn't work in the general case.  It happens to work if you don't
delete any dives, and dives only disappear as they are being overwritten
by new dives when the storage overflows.

But if you delete dives and then create new ones, the dive list will not
be sorted at all, and we should sort it properly when downloading.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-08 13:38:45 +02:00
Jef Driesen
cac0eb7d81 Remove the salinity compensation
In recent hwos firmware versions, the depth is no longer stored as
pressure (in millibar), but directly as depth (in meters) with the
salinity and gravity factor already applied.
2020-06-03 14:08:02 +02:00
David Carron
ee84202b2b Add support for the McLean Extreme dive computer
Initial support for McLean Extreme

Signed-off by: David McLean Carron <david_de_carron@hotmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-18 09:52:17 -07:00
Jef Driesen
9525bc8047 Fix the hwOS ppO2 bug for firmware v3.08
The hwOS ppO2 firmware bug is also present in firmware 3.08. See commit
b9a3606f379c3c9f57bbf561bdcb52fb76b711db for more details.
2020-05-13 16:45:53 +02:00
Linus Torvalds
48e46cf777 Shearwater: add extended information parsing
This adds the string field interface to the Shearwater family of dive
computers.

That includes proper serial number formatting, but it also has a lot of
new fields for battery information (both the dive computer itself and
the transmitter) but also deco model information.

Much of the deco model cases come from Anton Lundin in the original
subsurface branch, and Dirk Hohndel added the battery type and serial
number and firmware version data.  And I ended up massaging it even in
that original branch, so it blamed me for all these lines even back
there.

The sign-offs from Dirk and Anton are from the original commits.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
v4.9.6 v4.9.5
2020-05-07 15:14:10 -07:00
Linus Torvalds
53f82e4ac9 Shearwater: fix (again) per-cell ppO2 reporting
This re-applied commit 902dbf4d6d24 ("shearwater: Fallback to
average/voted ppo2") which got lost in the last merge with upstream when
I synced with Jef's rewrite of the PNF parser.

Reported-by: Martin Long <martin@longhome.co.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 15:12:43 -07:00
Dirk Hohndel
cb7f47b60b Shearwater Teric: add support for the TAG INFO_EVENT
This logs every INFO_EVENT record and provides a SAMPLE_EVENT_BOOKMARK
event for the only INFO_EVENT we can parse so far, the TAG event.

Three bits in the flag value in that event structure are now used to
hold the tag type, and if a non-zero type has been set, then the value
is the heading in degress.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 15:10:54 -07:00
Linus Torvalds
cdfbe4092d Shearwater Petrel: make the hardware ID decoding a bit easier to read
Dirk seems to have some documentation about the different ID's, plus it
just makes sense to order the switch statement by number.

This is partly based on Dirk's original commit to do the different model
numbers, with various changes over time due to merge conflict
resolution.  Dirk's sign-off comes from Dirks commit in the original
subsurface branch.

As of firmware 11, Teric identifies as 0x1F0A.

Also, just like libdivecomputer upstream, don't assume that an unknown
model is a Petrel - that was a stupid thing to do and caused downloads
with the Teric to break.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Shearwater parser: add new harware model nr for Teric

As of firmware 11 at least my Teric identifies as 0x1F0A.
Also, just like libdivecomputer upstream, don't assume that an unknown
model is a Petrel - that was a stupid thing to do and caused downloads
with the Teric to break.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 15:05:37 -07:00
Linus Torvalds
cf6c0d6640 Cressi: mark Cartesio and Goa as supporting BLE
They don't actually have any native BLE capabilities, but there's a "HAL
9000" docking station with bluetooth capability (and a USB cable for
wired connectivity).

This will need more work, the BLE communication is packetized
differently from the regular serial one.  But I'm keeping this
difference from Jef's upstream for posterity.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 15:05:37 -07:00
Dirk Hohndel
6042aa8875 Mark Aqualung i750TC as Bluetooth capable
There is also an i300C that is Bluetooth capable, but I don't know if
that's the same model as the i300 or a different variation.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07 15:05:37 -07:00
Linus Torvalds
680752bc0f i770R: parse tank pressure and water salinity like the i750tc
This needs to be checked.  I'm not sure why Jef has different code here,
but I'm keeping our Subsurface branch differences around.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 15:05:37 -07:00