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>
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
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.
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).
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.
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>
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>
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>
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
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
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
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>
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>
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>
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>
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
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>
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.
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.
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.
The purpose of the new I/O interface is to provide a common interface
for all existing I/O implementations (serial, IrDA, bluetooth and USB
HID). With a common interface the dive computer backends can more easily
use different I/O implementations at runtime, without needing
significant code changes. For example bluetooth enabled devices can
easily switch between native bluetooth communication and serial port
emulation mode.
The new interface is modelled after the existing serial communication
api. Implementations where some of those functions are meaningless (e.g.
IrDA, bluetooth and USB), can just leave those functions unimplemented
(causing the call to fail with DC_STATUS_UNSUPPORTED), or implement it
as a no-op (always return DC_STATUS_SUCCESS).
Nick Shore reports that it seems to act exactly like an EON Steel, just
with a different USB device ID.
Acting like the EON Steel is not a surprise: it does seem to be the same
dive computer, just in a smaller and lighter package (same screen size,
but more compact body and without the stainless steel to make it less
than half the weight). Looks like the battery is smaller, but the
electronics are likely the same.
We probably really should have some way to add new device ID's without
having to add whole new model numbers etc. It's not the first time this
happens (see the Scubapro Aladin Square vs the G2), and it's likely not
the last time.
Reported-by: Nick Shore <support@mac-dive.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
With the new APOS4 firmware, both the tts and the duration of the first
deco stop are recorded while in deco. But compared with the older
firmware, the tts field has moved to a slightly different offset. And
contrary to the new documentation, it seems that the value for invalid
or infinite has also changed from 0xFFFF to 0x7FFF,
Note that for dives recorded with an older firmware version, the
duration of the first deco stop isn't available, and libdivecomputer
reports the tts instead. This is the same behaviour as before.
Reported-by: Janice McLaughlin <janice@moremobilesoftware.com>