1691 Commits

Author SHA1 Message Date
Linus Torvalds
d02f1c3cdc Suunto EON Steel: set date too when doing device timesync
I'd never noticed this before, since my date had always been already set
correctly, but the timesync with the EON Steel only set the time, not
the date.

The fix is trivial, since the code already filled in the datetime data,
it just didn't do the SET_DATE command.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
v4.7.8
2018-04-01 09:56:47 -07:00
Dirk Hohndel
0e0ee16ea6 Correctly fix build without HID support
Suggested by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-31 11:49:42 -07:00
Dirk Hohndel
156cac65b6 Revert "Allow compilation on platforms without USBHID support"
This reverts commit 7444cca876cf1637fd7c3d4ad1e48145b215aed8.

The commit does what it advertises - but also breaks HID support everywhere
else. Oops.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-31 11:49:31 -07:00
Dirk Hohndel
9cda25a98b
Merge pull request #14 from torvalds/Subsurface-branch
Merge with upstream libdivecomputer
2018-03-13 22:33:47 -07:00
Linus Torvalds
c52becf6d4 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-branch
Merge with upstream:

 - support for the OSTC 2 TR

 - add support for dive computer filtering for device discovery

 - various cleanups particularly to timestamp handling

 - remove half-duplex emulation from the I/O api

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Remove the half-duplex emulation from the I/O api
  Handle the half-duplex emulation in the vyper2 backend
  Use the new timer for the timestamps in the logging
  Use the new timer for the timeout calculations
  Add a high resolution timer module
  Add functions for converting bluetooth addresses
  Add support for the OSTC 2 TR
  Add a workaround for invalid logbook begin pointers
  Let the ringbuffer function handle a full ringbuffer
  Suppress the warning if no O2 sensors are present
  Integrate the connect step into the open function
  Implement some filter functions
  Add suport for applying a filter function
  Re-write the device discovery using the iterator api
  Cleanup the iterator internals
2018-03-11 12:43:59 -07:00
Linus Torvalds
5b54386dbd remove the transfer type comments from the descriptor array
This basically reverts commit 4a3f7a7cce54 ("Mark DC descriptors with
supported transport").

The commit wasn't wrong, but it ends up having caused a *lot* of pain
for merging, because it adds the transfer type marker to most lines in
that descriptor array, and the end result is very painful to merge if
upstream libdivecomputer ever changes any of the array entries (which
happens fairly regularly, either because of format changes, or because a
new entry is added).

It's probably better and simpler to simply have some entirely separate
model for figuring out which dive computer supports which protocol.
There are enough common rules (like "old Suunto models are all FTDI")
that such a separate table probably would be simpler and clearer anyway.

This does not implement such a table, though - it just removes the
information entirely.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-03-11 12:19:42 -07:00
Linus Torvalds
f4e43afad9 remove 'serial' number from descriptor array
I added this long ago as a merge fixup (see commit f9db4ca97c4b: "Merge
git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch"),
because some of the OSTC parser_create() functions take a serial number.

However, the serial number is never actually taken from the descriptor
array, and if it was, it would be incorrect anyway.  None of the entries
in the descriptor array actually have any, so it's always zero.

So just remove it, because it's a big pain whenever upstream changes the
descriptor array format.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-03-11 12:19:42 -07:00
Linus Torvalds
f5e10ff9bc get rid of annoying compile warnings
This gets rid of the warnings in the build, mostly by just disabling
them entirely, and in one case by adding a default statement to make the
compiler not warn about lacking case statements for a switch()
statement.

Some of the warnings really don't work that well for libdivecomputer
(warning about pointer signs is very annoying when we mix regular
strings and various "unsigned char *" raw data).

And some of the warnings we should probably re-enable once by one, and
actually fix up.

But even the ones we should re-enable are right now more of a pain than
they are worth, and nobody has had the energy to do so.  And as long as
there are *so* many warnings, nobody likely will.

In the meantime, this gets rid of the harmless warnings, so that we can
see if any *bad* warnings happen.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-03-11 12:19:42 -07:00
Jef Driesen
38ff1f75dd Remove the half-duplex emulation from the I/O api
Now that the half-duplex emulation code isn't used anymore, it can be
removed from the I/O stream api.
2018-03-05 09:08:21 +01:00
Jef Driesen
4897a8351b Handle the half-duplex emulation in the vyper2 backend
The half-duplex emulation is basically a workaround for a timing problem
in the vyper2 backend. Since no other dive computer backend uses or
needs this feature, it makes no sense to support this at the I/O layer.
It can be implemented directly in the vyper2 backend instead.
2018-03-05 09:08:21 +01:00
Jef Driesen
ee31f24cfb Use the new timer for the timestamps in the logging
Replace the platform specific code with the new timers.
2018-03-05 09:08:21 +01:00
Jef Driesen
eb4c150024 Use the new timer for the timeout calculations
Replace the gettimeofday() based implementation with the new monotonic
timers. This makes the implementation more robust against unexpected
adjustments of the clock.
2018-03-05 09:08:21 +01:00
Jef Driesen
a8adb16c0d Add a high resolution timer module
The new timer module provides an cross-platform interface for a high
resolution monotonic clock. The timestamps are always relative to the
creation of the timer and their unit is one microseconds.

The timers can be used for logging, measuring elapsed time and
implementing timeouts.
2018-03-05 08:44:14 +01:00
Jef Driesen
becaf02ab6 Add functions for converting bluetooth addresses 2018-03-04 20:49:49 +01:00
Jef Driesen
efd47cd9a1 Add support for the OSTC 2 TR
The OSTC 2 TR add supports for one or more tank pressure transmitters,
and the active transmitter is linked to the active gas mix.
2018-02-17 10:22:44 +01:00
Dirk Hohndel
7444cca876 Allow compilation on platforms without USBHID support
E.g. iOS.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-02-12 12:25:25 -08:00
Dirk Hohndel
8cf5209d31 Revert "Shearwater: correctly handle the different models"
This reverts commit 8ea8cebb4e6c3d86b9ceb2291caa077dabd2a3f7.

Well intended, but as Jef points out it breaks download from older Shearwater
dive computers in certain situations.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
v4.7.7
2018-02-07 08:14:56 -08:00
Jef Driesen
0ac15dffd3 Add a workaround for invalid logbook begin pointers
Unfortunately there are several devices where an invalid logbook begin
pointer occurs relative frequently. Typical examples are the Oceanic VT
4.1 and the Sherwood Wisdom 2. In such cases, the strict validation of
the pointer causes the download to fail, without being able to download
any dives at all.

Since the begin pointer is only needed to detect the oldest logbook
entry, we can fall back to downloading the entire logbook ringbuffer. If
we're lucky (and we usually are), we can detect the oldest entry by
inspecting the logbook entries once they are downloaded (e.g. presence
of uninitialized entries) and then the download will finish succesfully.
In the worst case scenario, we'll be able to download at least some
dives before hitting another error.
2018-02-06 13:00:57 +01:00
Jef Driesen
05f5522210 Let the ringbuffer function handle a full ringbuffer
The ringbuffer_distance() function has a parameter to specify whether a
ringbuffer with identical begin/end pointers should be considered an
empty or a full ringbuffer. Hence there is no need to handle the case of
a full ringbuffer manually.
2018-02-06 13:00:34 +01:00
Jef Driesen
9117b593fc Suppress the warning if no O2 sensors are present
The warning about disabling the O2 sensors due to factory default
calibration values, applies only if there is at least one calibrated O2
sensor present.

This has no effect on the calibration bits, because those are already
zero if there are no calibrated O2 sensors present.
2018-02-05 19:58:22 +01:00
Jef Driesen
85eef19f8f Integrate the connect step into the open function
There is no need to expose the two step connection setup of the
underlying socket interface in the public api. Doing so may complicate
the implementation on platforms where the native api is not based on the
socket interface (e.g. Mac OS X).

Note that the function to connect based on the IrDA service name is
removed. It's not used anywhere in libdivecomputer and since IrDA is an
outdated technology nowadays, it's unlikely we'll need it in the future.
2018-02-04 21:21:42 +01:00
Jef Driesen
695212ddf8 Merge branch 'discovery' 2018-02-04 21:21:42 +01:00
Jef Driesen
0ce3bd3e6d Implement some filter functions 2018-02-04 21:21:42 +01:00
Jef Driesen
30e4060817 Add suport for applying a filter function
The device descriptors are extended with a filter function. During the
device discovery, this filter function is used to return only devices
that match a known dive computer.

The filtering is optional, and can be disabled by passing a NULL pointer
for the device descriptor when creating the iterator with one of the
dc_xxx_iterator_new() functions.
2018-02-04 21:21:42 +01:00
Jef Driesen
ca91500ed5 Re-write the device discovery using the iterator api
Replacing the callback based interface with an iterator based interface,
results in a more extensible abstraction with a common interface for
each of the built-in I/O implementations (serial, usbhid, irda and
bluetooth).
2018-02-04 21:21:16 +01:00
Linus Torvalds
fb0d0b269e Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-branch
Merge with upstream.

* git://github.com/libdivecomputer/libdivecomputer:
  Simplify the conditional compilation
  Disable some Windows specific compiler warnings
  Use SDP to auto-detect the rfcomm port number
  Use the actual IrDA device names
  Use the correct data type for the temperature
  Disable O2 sensors with default calibration values
  Add support for the Seac Jack
  Check for memory allocation errors
  Erase the buffer before calling the vtable function
  Replace hardcoded size with the sizeof operator
  Use the correct model number for the Shearwater Nerd 2
2018-01-31 10:57:02 -08:00
Jef Driesen
296fad2d9d Cleanup the iterator internals 2018-01-30 22:00:41 +01:00
Jef Driesen
f992d201ad Simplify the conditional compilation
Move the global variables inside an existing conditionally compiled
block, to remove some of the #ifdef's.
2018-01-30 21:21:21 +01:00
Jef Driesen
931d1857ce Disable some Windows specific compiler warnings
The -Wno-pedantic-ms-format option is only needed for the MinGW target.
But for some reason, the AX_APPEND_COMPILE_FLAGS macro enables the
option for all other GCC targets too. But during compilation GCC outputs
the warning "unrecognized command line option".
2018-01-30 21:21:21 +01:00
Jef Driesen
90eed3c790 Use SDP to auto-detect the rfcomm port number
When the port number is set to zero (which is an invalid value), detect
the port number automatically. On Windows, we can simply supply the UUID
of the serial port service, and the Windows api will take care of the
discovery. On Linux (bluez), the SDP discovery needs to be performed
manually to retrieve the port number.
2018-01-30 21:21:21 +01:00
Jef Driesen
6d5ac37f99 Use the actual IrDA device names 2018-01-30 21:21:21 +01:00
Jef Driesen
9e169c9a3f Use the correct data type for the temperature
Temperatures are reported as a floating point values and not as
(unsigned) integers.
2018-01-30 21:20:53 +01:00
Jef Driesen
3e36cad5ee Disable O2 sensors with default calibration values
If all (calibrated) sensors still have their factory default calibration
values (2100), they are probably not calibrated properly. To avoid
returning incorrect ppO2 values to the application, they are manually
disabled (e.g. marked as uncalibrated).
2018-01-30 19:56:49 +01:00
Jef Driesen
9ca91ca584 Add support for the Seac Jack
The Seac Jack is compatible with the DiveSystem/Ratio dive computers.
2018-01-30 19:52:27 +01:00
Jef Driesen
0ae9e355f8 Check for memory allocation errors
Appending data to the buffer may fail if a memory allocation is
necessary to enlarge the buffer. Hence the return value of the
dc_buffer_append() call should always be checked, unless the memory was
already pre-allocated or the check is deferred after the last operation.
2018-01-29 15:06:58 +01:00
Jef Driesen
c194f559d8 Erase the buffer before calling the vtable function
This guarantees that the backend will always receive an empty buffer,
and eliminates the need to clear the buffer manually in every single
backend.
2018-01-09 15:54:44 +01:00
Jef Driesen
d23bc6e089 Replace hardcoded size with the sizeof operator 2018-01-09 15:54:44 +01:00
Jef Driesen
c3556d81c9 Use the correct model number for the Shearwater Nerd 2
Unlike the Shearwater Petrel, the Shearwater Nerd 2 appears to have a
distinct model number from the Nerd.

Reported-by: Janice McLaughlin <janice@moremobilesoftware.com>
2018-01-09 15:53:52 +01:00
Linus Torvalds
70ad30bed3 Merge branch 'master' of git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge with upstream.

This is Dirk's Coverity patches, just gone through Jef to avoid
unnecessary merge issues.

* git://git.libdivecomputer.org/libdivecomputer:
  Cleanup: remove confusing NULL check
  Cleanup: bail on error
  Cleanup: consistently check return value of iostream functions
  Cleanup: check return value of ioctl()
  Cleanup: remove dead code and return the correct return code
  Cleanup: avoid undefined shift operation
  Cleanup: ensure string is 0 terminated
  Cleanup: avoid memory leak
  Cleanup: avoid memory leak
  Cleanup: avoid memory leaks
  Cleanup: correctly handle upper bound of array
2018-01-04 15:34:15 -08:00
Dirk Hohndel
fb8115cbc6 Scubapro G2 cleanup: avoid memory leak
Coverity CID 207807

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-01-04 15:33:29 -08:00
Jef Driesen
21b0f01852 Merge branch 'coverity' 2018-01-04 20:23:50 +01:00
Dirk Hohndel
4335c9b9eb Cleanup: remove confusing NULL check
device has already been dereferenced before we ever get here

Coverity CID 207713
Coverity CID 207780

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-01-04 19:46:54 +01:00
Dirk Hohndel
4144e0c7ff Cleanup: bail on error
Coverity CID 207809

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-01-04 19:46:54 +01:00
Dirk Hohndel
2f097e54fe Cleanup: consistently check return value of iostream functions
Coverity CID 215197
Coverity CID 215200

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-01-04 19:46:54 +01:00
Dirk Hohndel
4e93b9a8f8 Cleanup: check return value of ioctl()
It's checked for all the other invocations...

Coverity CID 207796

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-01-04 19:46:54 +01:00
Dirk Hohndel
e22adbb3f9 Cleanup: remove dead code and return the correct return code
Coverity CID 207700

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-01-04 19:46:54 +01:00
Dirk Hohndel
88cc5e1413 Cleanup: avoid undefined shift operation
Shifting a 32bit value by 32 is undefined.

Instead of using shifts to create the mask, explicitly create it by
subtracting 1 from the signbit value (and using bitwise NOT to fill all
the higher bits).

This commit looks confusing because Jef wanted me to not have two places
where I use the bitwise not. So instead of creating an equivalent mask
variable and not having to change the return statements we end up with a
mask that is the bitwise invert of what was there before this commit and
therefore the return statements need to change as well.

Coverity CID 207769

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-01-04 19:46:54 +01:00
Dirk Hohndel
71f76819c0 Cleanup: ensure string is 0 terminated
The Linux kernel uses the sir_name as a standard C string (in one
instance copying it into a 60 char buffer using kstrncpy with a length
limit of 60), we therefore need to ensure that it is 0 terminated.

Since the existing code didn't notify the caller if we were truncating
the string at 25 characters, I didn't add such a warning/error for
truncating at 24 characters.

I was not able to find documentation on how Windows uses irdaServiceName
but since this is implementing the same standard, the same change was
made to the Windows code.

In both cases I replaced the hardcoded length of 25 with a sizeof()
argument (but both Linux and Windows hard code that length in their
headers, so it seems unlikely this would ever change).

Coverity CID 207790

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-01-04 19:46:54 +01:00
Dirk Hohndel
5997caf45f Cleanup: avoid memory leak
Coverity CID 207731

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-01-04 19:46:54 +01:00
Dirk Hohndel
681720e96a Cleanup: avoid memory leak
Coverity CID 207773

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-01-04 19:46:54 +01:00