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>
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>
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
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>
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>
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>
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.
Replace the gettimeofday() based implementation with the new monotonic
timers. This makes the implementation more robust against unexpected
adjustments of the clock.
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.
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>
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.
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.
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.
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.
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.
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).
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
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".
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>