1776 Commits

Author SHA1 Message Date
Linus Torvalds
8fb2b75c25 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge Jef's upstream updates.

Trivial conflicts just because of whitespace differences and a comment
difference in our Suunto D5 support changes.

* git://github.com/libdivecomputer/libdivecomputer:
  Add support for the Suunto D5
  Add support for the Tusa Talis
  Add the G2 HUD bluetooth device name
  Detect Mares Quad with more flash memory
  Fix the limit for an invalid sample temperature
  Fix a buffer overflow
2019-05-31 09:49:17 -07:00
Jef Driesen
0dc10062ce Add support for the Suunto D5
The Suunto D5 is fully compatible with the Eon Steel, except for the
different USB PID.

Reported-By: Nick Shore <support@mac-dive.com>
2019-05-27 09:06:13 +02:00
Jef Driesen
b188c41420 Add support for the Tusa Talis
Reported-By: Nick Shore <support@mac-dive.com>
2019-05-27 09:06:13 +02:00
Jef Driesen
629e33432f Add the G2 HUD bluetooth device name 2019-05-27 09:06:13 +02:00
Jef Driesen
7b29c5d43d Detect Mares Quad with more flash memory
The latest variant of the Mares Quad has 4 times more flash memory
compared to the original variant (1M vs 256K). Therefore this variant
supports a new command to read the size of the flash memory.

At the moment, it's unknown whether the previous variant also supports
this new command or not. Probably not, because none of the other
compatible models seems to support it either. Hence we only attempt to
read the flash memory size for the Quad, and a failure is not considered
a fatal error. The disadvantage of this approach is that a temporary
communication problem can result in a misdetection of the flash memory
size.

Reported-by: Janice McLaughlin <janice@moremobilesoftware.com>
2019-05-27 08:54:27 +02:00
Janice McLaughlin
5c55760fd5 Fix the limit for an invalid sample temperature
In the EON Steel descriptor for the temperature field, the "nillable"
value is -3000:

   int16,precision=2,nillable=-3000

So the missing equals sign is just a small oversight.
2019-05-24 11:14:13 +02:00
Linus Torvalds
1194585595 Add support for Suunto D5 dive computer
It looks just like a small-form-factor EON Steel/Core, just with new
device IDs.

I haven't been able to pair over BLE yet, but that may be the usual
"Suunto wants to do a private bonded pairing" thing that makes it a pain
on the desktop.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-16 14:42:22 -07:00
Jef Driesen
05a21bc8ee Fix a buffer overflow
The length field in the data is checked for the maximum size (e.g. the
size of the buffer), but there is no such check on the minimum size
(e.g. the size of the header). If the length is smaller, the code
accessed data before the start of the buffer.
2019-05-10 16:02:01 +02:00
Linus Torvalds
92cf2f8fa1 Suunto EON Steel/Core: make sure to properly sort the dive list
I incorrectly thought it was already sorted in the directory listing,
but once the dive list start overflowing, it looks like the ordering
goes away.

So sort the dives explicitly by date, rather than depend on any existing
ordering when reading the list of dives.

Reported-by: PM <boesch76@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-05 14:19:43 -07:00
Linus Torvalds
e650acc052 Garmin: be more permissive about the activity type
We used to require that we have one of the documented dive types in the
'sub_sport' type field.  But apparently Garmin added a new type number
for CCR diving, so CCR dives weren't recognized at all.

Add the new CCR case, but also say that if we have seen a DIVE_SUMMARY
record with average depth information, we'll just assume it's a dive
even for unrecognized sub_sport numbers.

Reported-by: Thomas Jacob <opiffe@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-05 10:00:27 -07:00
Linus Torvalds
2971cc20ff Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Pull upstream updates from Jef Driesen.

This adds ID entries for the Scubapro G2 HUD (but no GPS parsing support
yet) and the Aladin H Matric.

Also fix ndl/deco parsing for for Aqualung i450T.

* git://github.com/libdivecomputer/libdivecomputer:
  Fix the ndl/deco sample for the Aqualung i450T
  Add support for the Scubapro G2 HUD
  Add support for the Scubapro Aladin H Matrix
2019-04-24 09:04:42 -07:00
Jef Driesen
f37c3d3c86 Fix the ndl/deco sample for the Aqualung i450T 2019-04-24 16:23:11 +02:00
Jef Driesen
74957542bb Add support for the Scubapro G2 HUD
The G2 HUD is compatible with the G2, except for the new USB PID.
2019-04-23 10:00:08 +02:00
Jef Driesen
7d48587ed8 Add support for the Scubapro Aladin H Matrix
The Aladin H Matrix appears to be identical to the Aladin Sport Matrix.
2019-04-23 09:59:24 +02:00
Linus Torvalds
c7112237b3 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream updates from Jef:

 - better Mares Bluelink Pro downloading

 - Suunto DX CCR and gas mix fixes

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Add support for the Mares Bluelink Pro interface
  Check the correct vtable pointer
  Report the setpoint data
  Take the CCR diluents into account
  Implement the initial gas mix
  Get the gas mix index directly from the event data
2019-04-15 08:53:33 -07:00
Jef Driesen
019a98f80c Add support for the Mares Bluelink Pro interface
The main difference with the serial communication is that the BLE
communication uses data packets (with a maximum size of 20 bytes)
instead of a continuous data stream.

Occasionally, the device responds with an empty packet (with just the
ACK and EOF byte) or with a short packet where one or more payload bytes
are missing. The empty packet is most likely caused because the device
didn't receive the second part of the command (with the parameters) in
time. The missing bytes might be caused by a buffer overflow on the
Bluelink Pro, when the data from the dive computer arrives faster over
the serial link than the device can forward it over the slower bluetooth
link to the host system.

One way to address this problem is to lower the packet size from 256 bytes
to only 128 bytes. The main disadvantage is that this also impacts the
download speed considerably. In one particular example, the total
download time increased from about 135 to 210 seconds (which is already
slow compared to the 62 seconds the same download takes over usb)!

An alternative solution is to simply retry the failed command. That way
there is only a performance penalty for the few bad packets, and not for
every single packet. In the above example, only two packets needed a
retransmission.

Note that the iconhd communication protocol uses no checksums. Hence
it's not possible to detect corrupt data packets. Only short packets can
be detected, because they result in a timeout.
2019-04-14 19:55:14 +02:00
Jef Driesen
88a814a616 Check the correct vtable pointer 2019-04-14 11:25:12 +02:00
Jef Driesen
01ec0c0970 Merge branch 'suunto-dx' 2019-04-13 11:37:33 +02:00
Jef Driesen
6ee786c31a Report the setpoint data 2019-04-13 11:37:15 +02:00
Jef Driesen
8a70885f89 Take the CCR diluents into account
The Suunto DX supports 3 CCR diluents and 8 OC gas mixes. Since the gas
mix index in the data is relative to either the set of CCR diluents or
OC gas mixes (depending on the dive mode) and libdivecomputer reports
both sets, the index needs to be adjusted.
2019-04-13 11:37:06 +02:00
Jef Driesen
6867ffb143 Implement the initial gas mix
Initialize the initial gas mix correctly from the data in the dive
header, instead of always using the first gas mix.
2019-04-13 11:23:36 +02:00
Jef Driesen
5116ee8f2d Get the gas mix index directly from the event data
There is no need to lookup the gas mix index, because the number is
stored directly in the event data, right next to the oxygen and helium
values. This actually removes an ambiguity in cases where the user has
configured two or more identical gas mixes. In that case, the lookup
would always find the first gas mix.
2019-04-13 11:15:53 +02:00
Dirk Hohndel
e4698c4844 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>
v4.8.6
2019-03-16 12:23:28 -07:00
Linus Torvalds
d0ec5cf760 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge with upstream from Jef:

 - ignore empty pressure samples from OSTC

 - skip empty Oceanic logbook entries

 - update Ratio parsing

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Ignore zero tank pressure values
  Add filters for BLE communication
  Skip empty logbook entries
  Add clock synchronization support
  Use symbolic constants for the commands
  Don't pass a NULL pointer to memcpy
  Update the list of the Ratio dive computers
2019-03-12 17:00:19 -07:00
Linus Torvalds
1953d7a5a1 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>
2019-03-12 16:55:25 -07:00
Jef Driesen
530b28bf6f Ignore zero tank pressure values
When the connection with the transmitter is lost, the OSTC records a
zero value for the tank pressure.
2019-03-06 11:05:27 +01:00
Jef Driesen
2ea24cf043 Add filters for BLE communication
This is mainly for future use and reference, because there is still no
built-in support for BLE communication available.
2019-03-06 11:05:27 +01:00
Jef Driesen
f05f60c4ad Skip empty logbook entries
On certain devices, for example the Aeris Elite T3, the logbook
ringbuffer can sometimes contain an empty logbook entry in between the
valid entries. Because the presence of such an empty entry is currently
being interpreted as having reached the last valid entry, the download
is aborted. The result is that all remaining valid entries, located
after the empty entry, can't be downloaded.

This can be avoided by skipping the empty entry instead of aborting the
download.
2019-03-06 11:04:53 +01:00
Jef Driesen
81bca1ff7c Merge branch 'ratio' 2019-02-22 14:23:33 +01:00
Jef Driesen
4bbebe7c32 Add clock synchronization support
The Ratio dive computers support synchronizing the internal clock. One
complication is that recent firmware versions (4.0.56 or 4.1.10) support
two timezones (home and abroad), while the libdivecomputer api only
supports one timezone. To deal with this, the most recent firmware
versions (4.0.58 or 4.1.12) will interprete an invalid timezone index
(0xFF) as leaving the timezone unchanged.

If the firmware doesn't support the dual timezone command, or if the
firmware doesn't have the invalid timezone index modification yet, then
a fallback to the single timezone command is provided. Note that in the
latter case the side effect is that both timezones will be changed!
2019-02-22 14:21:51 +01:00
Jef Driesen
ec14ee2b77 Use symbolic constants for the commands 2019-02-22 14:21:51 +01:00
Jef Driesen
d876542d39 Don't pass a NULL pointer to memcpy
The memcpy and related functions expects a valid pointer, even if the
size is zero. Most libc implementations will handle a NULL pointer just
fine, but that's not guaranteed.

Simply skip the call when there is nothing to copy.
2019-02-22 14:21:51 +01:00
Jef Driesen
3287e3bd5d Update the list of the Ratio dive computers
There were quite a few models missing in the list. And because the
lowest iX3M model number has changed, the iX3M detection needed to be
updated as well.
2019-02-22 14:21:51 +01:00
Linus Torvalds
072bef1666 shearwater: properly initialize the string caches
The merge with Jef's upstream ended up taking a lot of Jef's changes to
how the Shearwater PNF parsing was done, and in the process inadvertdly
lost some of the code from our side of the branch that Jef hadn't taken.

In particular, the initialization of the string cache, and the
logversion string.

Put them back.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
v4.8.5
2019-01-23 13:28:39 +13:00
Dirk Hohndel
391c4095f2 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>
2019-01-23 09:08:10 +13:00
Linus Torvalds
1d09635a58 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Update with Jef's upstream:

 - add support for Cressi Goa and Cartesio

 - update the Shearwater PNF parser to Jef's version

 - misc minor fixes

* git://github.com/libdivecomputer/libdivecomputer:
  Use the timezone setting of the dive computer
  Add support for the Cressi Goa and Cartesio
  Add an extra parameter for the initial CRC value
  Add support for the Ratio iDive Color series
  Shearwater Petrel Native Format parsing
  Shearwater: detect which logbook format is support
  Shearwater: add Teric to list of supported dive computers
  Shearwater: skip deleted dives
  Fix a potential buffer overflow
2019-01-22 12:15:37 +13:00
Jef Driesen
2b96b2f52c Use the timezone setting of the dive computer
The Ratio dive computers with the latest APOS4 firmware support a
timezone setting. Take this timezone into account instead of using the
timezone of the host system.
2019-01-18 14:44:46 +01:00
Jef Driesen
e363e5b1fd Add support for the Cressi Goa and Cartesio 2019-01-14 21:14:30 +01:00
Jef Driesen
da2582237f Add an extra parameter for the initial CRC value
This allows to calculate different variants of the CRC-CCITT algorithm
with a single function.
2019-01-08 15:20:05 +01:00
Jef Driesen
4c93e14b0e Add support for the Ratio iDive Color series
The new iDive Color series uses the same communication protocol and data
format as the previous models.
2019-01-08 08:22:23 +01:00
Jef Driesen
179ec4688f Merge branch 'shearwater' 2018-12-21 10:44:50 +01:00
Jef Driesen
47bb08bbfd Shearwater Petrel Native Format parsing
This will allow parsing dives from the Shearwater Teric, but depending on the
firmware could also be used on older models.

Based on ideas and code from Dirk Hohndel
2018-12-20 13:45:32 +01:00
Dirk Hohndel
ae503626ae Shearwater: detect which logbook format is support
The Log Upload RDBI (Read Data by Identifier) response tells us which
format the dive computer supports.

Shearwater recommends to use the 'Petrel Native Format' for all dive
computers which support it, even those pre-Teric models which (depending
on firmware) might support both PNF and the older 'Predator-Like
Format'.

They also recommend to ignore the 0x90000000 format which is very
similar to PNF but without the final record and to use the older
Predator Like Format in that case.

The 0xDD000000 format is never an option by the time you got here, but
in the old code (prior to the PNF addition) we would have fallen back to
0xC0000000, so let's do the same here.

Any other value is actually an unknown format and should be treated as
such.

Which format we use is determined by the base address used to download
the logbook entries.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-20 13:45:32 +01:00
Dirk Hohndel
472e73118d Shearwater: add Teric to list of supported dive computers
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-20 13:45:32 +01:00
Dirk Hohndel
864b40cb3d Shearwater: skip deleted dives
Without this change a deleted dive on device is treated like the end of the
dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-20 13:45:32 +01:00
Jef Driesen
0b2959d8c7 Fix a potential buffer overflow
Check whether there is space available for a complete sample, and not
just a single byte!
2018-12-18 08:57:54 +01:00
Linus Torvalds
e4c96e93ca Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge with upstream from Jef.

Small trivial fixlets.

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Fix the Cobalt 2 memory size
  Use the travis homebrew plugin to install packages
  Increase the internal log buffer
  Fix undefined behaviour in left shifts
2018-12-17 09:32:47 -08:00
Linus Torvalds
33253b2f8c Fix OCEANIC_COMMON_MATCH pattern matching for BLE versions
It seems that the BLE communication protocol is somewhat different from
the serial one in the version string: while the serial version tends to
show the memory size, the BLE version string has some other numeric
pattern.

We don't have enough information to guess what it is, although normally
the BLE pattern is just "0001" instead of some memory size string.  But
I've seen the i770R once report 0090 instead.  Some status code?

Regardless, make the Pro Plus X and the I300C pattern simply ignore the
last four digits, since they clearly vary, and those two computers
support BLE.

The i770R pattern already did that, since I saw it myself.  The Pro Plus
X I have a communication trace from Brett Woods, and the i300C I just
assume follows the same pattern.

Reported-by: Brett Woods <brett@jeepswag.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-17 09:24:24 -08:00
Jef Driesen
c622998fb1 Fix the Cobalt 2 memory size
The Cobalt 2 has a bit more flash memory available for storing dives
compared to the original Cobalt 1. This larger amount of memory can
cause the progress events to exceed past 100% if there are many dives
present. This will trigger the assert in the event code and crash the
application.
2018-12-17 16:44:48 +01:00
Linus Torvalds
b082a96ebb Enable BLE support for the Oceanic Pro Plus X
It really looks (very superficially) like the Oceanic Pro Plus X might
act exactly the same as the Aqualung i770R over bluetooth: it has the
exact same bluetooth name pattern ("ER001299", where "ER" is the ASCII
represetnation of the model number (0x4552) and the 001299 looks like
the serial number that we then use for "authenticating" with the device.

I haven't actually tested this at all, but Brett Woods sent the
bluetooth scan information, and it looks promising.  So let's just test
it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-14 13:45:17 -08:00