1669 Commits

Author SHA1 Message Date
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
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
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
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
Dirk Hohndel
96e6bf5848 Cleanup: avoid memory leaks
Coverity CID 207730
Coverity CID 207747

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-01-04 19:45:40 +01:00
Dirk Hohndel
bd00ddea17 Cleanup: correctly handle upper bound of array
Coverity CID 207684
Coverity CID 207724
Coverity CID 207728

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-01-04 19:45:40 +01:00
Linus Torvalds
c354ae0506 Merge branch 'master' of git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge with upstream libdivecomputer.

For once a trivial merge.  The most noticeable thing is the Mares Quad
Air support.

* 'master' of git://git.libdivecomputer.org/libdivecomputer:
  Fix a mistake in the error checking
  Add support for the Mares Quad Air
2018-01-03 12:04:00 -08:00
Jef Driesen
81f3fdd854 Fix a mistake in the error checking
This is a small bug that was introduced long time ago, with commit
84563c6303a4ab263ea19c973d3f0bbfe6fc0955.
2017-12-13 09:54:55 +01:00
Janice
a833992ed6 Add support for the Mares Quad Air 2017-12-13 09:50:52 +01:00
Dirk Hohndel
8ae735a4d7 Merge branch 'ignore-build' of https://github.com/janmulder/libdc into Subsurface-branch v4.7.6 2017-12-12 16:09:51 -08:00
Linus Torvalds
a1472a7247 Merge branch 'Subsurface-branch' of github.com:Subsurface-divelog/libdc into Subsurface-branch
Merge with Dirk's cleanups.

I had intentionally not updated my tree while I was pondering the
upstream merge with Jef's iostream changes, so I didn't have Dirk's
cleanups in my tree when I did that big merge.

This merge was trivial in comparison.

* 'Subsurface-branch' of github.com:Subsurface-divelog/libdc:
  Correctly determine git SHA if libdivecomputer is a git submodule
  Disable a couple of overly aggressive warnings
  Add configure flag to explicitly enable BLE support
2017-12-12 14:02:53 -08:00
Linus Torvalds
8a34d822ff Merge remote-tracking branch 'jef/master' into Subsurface-branch
Rough merge of upstream libdivecomputer.

This is mainly about making the new iostream code upstream, although we
don't actually use it.

It abstracts out the the old serial and usbhid code, but we end up still
using our own 'custom_io' interface because the iostream code doesn't do
it right.

* jef/master:
  Correctly determine git SHA if libdivecomputer is a git submodule
  Don't accept a NULL pointer as parameter
  Add support for semi-closed circuit diving
  Detect dives with invalid profile data
  Implement the serial communication functions as no-ops
  Move the socket code to a common file
  Add support for a custom I/O implementation
  Port the USB HID code to the new I/O interface
  Port the bluetooth code to the new I/O interface
  Port the IrDA code to the new I/O interface
  Port the serial code to the new I/O interface
  Add a new abstract I/O interface
  Post release version bump to 0.7.0
2017-12-12 13:59:29 -08:00
Dirk Hohndel
ca1efdcecd Correctly determine git SHA if libdivecomputer is a git submodule
In the case of a submodule, the .git file is a text file pointing to the
correct module in the parent's .git folder. The git rev-parse works
correctly in both cases.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-07 15:54:48 +01:00
Dirk Hohndel
db70c581a6 Correctly determine git SHA if libdivecomputer is a git submodule
In the case of a submodule, the .git file is a text file pointing to the
correct module in the parent's .git folder. The git rev-parse works
correctly in both cases.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
v4.7.5
2017-12-06 21:23:22 -06:00
Dirk Hohndel
f5aee8198f Disable a couple of overly aggressive warnings
-Wextra and -Wpedantic are creating more noise than useful warnings.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-04 13:53:40 -08:00
Dirk Hohndel
506bcec3cd Add configure flag to explicitly enable BLE support
This way BLE dive computers that are otherwise conditional on USBHID will be
built on platforms that support them but don't have USBHID (like iOS).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-04 13:42:25 -08:00
Linus Torvalds
77f87bebe3 EON Steel: remove a few unused variables
Most of the new warnings due to compiler flags are just unnecessary
noise, but let's clean up at least the obvious and unquestionably valid
ones.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-12-04 10:43:20 -08:00
Linus Torvalds
54f6bff929 Merge tag 'v0.6.0' of git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Sync up with upstream cersion 0.6.0.

Annoying merge, mainly because a lof of the changes Jef had done are
actually changes that came from our Subsurface branch, but in a
different form, because Jef doesn't actually take patches directly from
us.

Why? I don't know.

* tag 'v0.6.0' of git://git.libdivecomputer.org/libdivecomputer:
  Release version 0.6.0
  Fix some potential buffer overflows
  Fix some casts with constant pointers
  Enable some useful compiler warnings by default
  Generate html documentation from the manpages
  Fix the decoding of the ndl/deco information
  Decode the firmware version for the iDive series
  Add support for the Suunto Eon Core
  Locate the most recent dive
  Add EON Steel time sync capability
  Improve the progress events
  Detect the model number using the hardware type
  Shearwater: add support for remaining gas time
  Shearwater: extract tank sensor data for log version 7
  Shearwater: extract log version from header
2017-12-04 10:18:23 -08:00
Jan Mulder
8c443c5abc build: ignore the build from git
Now as a submodule, the change in libdivecomputer created by the
build process is annoying. Just ignore it.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-04 02:12:13 +01:00
Jef Driesen
42f8e012b7 Don't accept a NULL pointer as parameter
Immediately return an error instead of trying to pass the NULL pointer
to the underlying open system call.
2017-12-01 15:03:17 +01:00
Jef Driesen
f87720dff9 Add support for semi-closed circuit diving
Add a new type to distinguish between closed circuit (CCR) and
semi-closed circuit (SCR) diving. Some dive computers from HW and
DiveSystem/Ratio support this.

Because the CCR/SCR abbreviations are more commonly used, let's take the
opportunity to also rename the existing DC_DIVEMODE_CC. To preserve
backwards compatibility, a macro is added to map the old name to the new
one.

Reported-by: Jan Mulder <jlmulder@xs4all.nl>
2017-11-30 09:03:46 +01:00
Jef Driesen
76187c550a Detect dives with invalid profile data
The OSTC3 stores the dive headers and profile data in two separate
memory areas. There is a header area with fixed positions and a profile
area which is used as a ring buffer. Each dive header stores the
position of the profile data in the ring buffer.

Now, once there are more dive headers then room for the profiles, the
oldest profiles (but not the headers) are overwritten with new data.
Because the dive headers are not updated when their profile data gets
overwritten, they will now point to data that is no longer available.
The internal logbook detects this situation and does not display the
profile. But during the download, there is no such check, and the OSTC
will send invalid profile data.

This invalid profile data should be dropped on the receiver side.
Unfortunately implementing the exact same check as is done by the OSTC
itself isn't possible, because the OSTC doesn't send the 6 byte internal
header on which the check is based. As a workaround, the two byte
end-of-profile marker and the length field in the profile header is used
to detect overwritten profiles.
2017-11-30 09:03:46 +01:00
Jef Driesen
f98f5eba5f Merge branch 'iostream' 2017-11-26 23:07:57 +01:00
Jef Driesen
e22ba69819 Implement the serial communication functions as no-ops
For the socket based I/O stream implementations (IrDA and bluetooth) the
serial communication specific functions are meaningless. Implementing
them as no-ops allows the dive computer backends the call the I/O stream
functions unconditionally.

This is important for the bluetooth implementation, because bluetooth
enabled dive computers will be able to use both the native bluetooth
communication and the legacy bluetooth serial port emulation.
2017-11-26 23:00:33 +01:00
Jef Driesen
823303980e Move the socket code to a common file
A large part of the irda and bluetooth code is the Windows and BSD
socket code. Moving this code to a common file reduces code duplication.
2017-11-26 23:00:33 +01:00
Jef Driesen
283eaa1ca6 Add support for a custom I/O implementation
Wih the custom I/O implementation, an application can use its own
low-level I/O layer instead of using one of the built-in ones. The
application only needs to provide a set of callback functions, and
libdivecomputer will wrap them into a I/O stream.
2017-11-26 10:40:34 +01:00