The vendor_product_parser_create() and vendor_product_device_open()
functions should be called indirectly, through the generic
dc_device_open() and dc_parser_new() functions. And the
vendor_product_extract_dives() functions are internal functions that
should never have been part of the public api in the first place.
Merge upstream libdivecomputer changes from Jef Driesen.
No major changes and no conflicts except for a trivial one where Jef had
marked a couple of private functions 'static' and our versions had
extended the argument lists of those functions.
This just updates to the current upstream state of libdivecomputer,
where the bulk of the changes come mainly from the new ringbuffer helper
code, but there are various other small misc fixes and cleanups.
* git://git.libdivecomputer.org/libdivecomputer:
Disable the deco events
Replace the deco events with a deco sample
Report errors from the close function
Mark the private function as static
Fix a bug in the tank pressure samples
Disable freedive mode for the Uwatec Aladin Tec 2G
Mark the private function as static
Fix some compiler warnings
Fix some more null pointer dereferences
Use a more efficient download algorithm
Use the new ringbuffer stream
Add a common ringbuffer reading algorithm
Improve the robustness of the IrDA I/O code
Fix a few null pointer dereferences
Fix the number of gas mixes
Always use the sample timestamp as the base value
When compiled with older Microsoft libraries, the unsafe implemention of
snprintf results in non-null terminated strings, causing numerous subsequent
issues. This fix just enlarges the used buffer to accommdate longer strings.
A more complete solution would include the use more recent Microsoft libraries in
the build process. The larger buffer is still need then, to prevent trucated
(but proper null terminated) strings.
ref: https://github.com/Subsurface-divelog/subsurface/issues/301
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
When downloading a Shearwater Petrel using the predator backend, the
firmware version and serial number are different compared to those
reported by the petrel backend.
This is caused by a difference in the encoding of the data. In the
predator data format, the firmware version appears to be BCD encoded,
and the serial number is stored as a big endian integer.
The number of tank pressure sensors is not necessary equal to the number
of gas mixes. Take for example a dive with two gas mixes, but only a
single tank pressure sensor attached to one of the two tanks. Because
the tank index is shared with the gas mix index, it will refer to a
non-existing sensor when switching to a tank without a pressure sensor
attached.
The invalid tank index should not be considered a fatal error. The tank
pressure values should be ignored instead. The device appears to record
zero values anyway, except for the first value immediately after the gas
switch. I suspect that's caused by the fact that the pressure is only
recorded every 4 samples, and therefore the last pressure value is
reported with a small delay.
The Uwatec Aladin Tec 2G doesn't support freedive mode. This appears to
be a bug in SmartTrak and LogTrak. They both report gauge and air/nitrox
dives as apnea dives.
The current algorithm always downloads a full memory dump, and extracts
the dives afterwards. For the typical scenario where only a few dives
are being downloaded, this is inefficient because most of the data isn't
needed. This can easily be avoided by downloading the data on the fly.
Reading a ringbuffer backwards in order to process the most recent data
first, is a very common operation. Nearly every dive computer backend
has its own implementation. Thus with a common implementation, the
amount of code duplication and complexity in the dive computer backends
can be greatly reduced.
The common algorithm is implemented as a simple ringbuffer stream, which
takes care of all the technical details like the ringbuffer boundaries,
alignment to the page size, using the optimal packet size and caching
the remaining data.
The select system call modifies the file descriptor set, and depending
on the underlying implementation also the timeout. Therefore these
parameters should be re-initialized before every call.
The existing code also didn't handle EINTR and EAGAIN correct.
With a time based sample interval, the number of samples for a single
timestamp should be constant. However in practice some devices
occasionally store fewer samples. Since our sample time is based purely
on the sample interval, it goes completely out of sync with the sample
timestamp. To avoid this problem, the sample timestamp is used as the
base value.
For the Oceanic Pro Plus 2, this problem is very noticable. After about
115 minutes into a dive, the sample interval appears to increase to 60
seconds. Thus, without this fix, the resulting dive time for long dives
is suddenly much shorter than it should be.
The Aqualung i450T appears to ignore the fixed sample rate and instead
store a timestamp in each sample.
The presence of the surface samples in combination with this timestamp
based format is odd. Even the official Diverlog software is confused:
the Windows versions seems to ignore them, but the Mac version takes
them into account.
After the previous commit, the raw data is now reported with one large
vendor sample. Because that makes the data more difficult to interpret
(for example during debugging), a small helper function is added to
split the data again in multiple vendor samples.
Originally, the time and vendor sample values are emitted immediately
after the previous sample is complete. This is now postponed until all
raw samples are available.
This will be required for the Aqualung i450t. That model appears to
ignore the fixed sample rate and instead store a timestamp in each
sample. That means the timestamp is only available once the last raw
sample data has been reached.
Skipping the extra samples by increasing the length is not always
reliable. If there are empty samples present, they will get skipped
instead of the real samples. And if the number of samples isn't an exact
multiple of the samplerate, we're accessing data beyond the end of the
dive profile.
Merge upstream libdivecomputer changes from Jef Driesen.
The most notable one is how libdivecomputer no longer sends the
GASCHANGE events, but uses DC_SAMPLE_GASMIX instead.
We still turn it into a SAMPLE_EVENT_GASCHANGE2 event internally in
subsurface, since we want all the normal event handling to trigger.
* 'master' of git://git.libdivecomputer.org/libdivecomputer: (21 commits)
Document the date/time functions
Document the public api with man pages
Add support for the Cressi Drake
Detect overwritten dive profiles
Ignore tank pressure if no sensor is attached
Add support for the tank field
Add support for the salinity field
Use the sample interval from the settings
Update the Aqualung i750TC parser
Toggle the DTR line during setup
Implement the read function
Add doxygen documentation to the build system
Add support for the Aqualung i750TC
Fix the Windows version resource build
Force the dive mode to gauge
Add support for the dive mode
Report the initial gas mix on the first sample
Remove the deprecated gas change events
Add support for the Hollis DG02.
Add support for the Oceanic F10.
...
The code was just if instead of else if by accident.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
OSTC4 stores firmware in another format than OSTC3's.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This way we actually trace print the written buffer, even if the caller
doesn't care about how much data he/she actually wrote.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The Cressi Drake is a mainly a freedive computer. The data format is
almost identical to the Leonardo. The main difference is that a single
dive now contains an entire freedive session. Each freedive in the
session is delimited with a 4 byte header containing the surface
interval and a special marker.
The logbook entries are stored separately from the profile data. If the
profile ringbuffer is filled faster than the logbook ringbuffer, then
the oldest logbook entries can still point to profile data that has
already been overwritten with newer data.
To detect such overwritten profile data, we keep track of the remaining
space in the profile ringbuffer.
The sample interval is stored in the settings, and thus there is no need
to use a hardcoded value. In practice all dives appear to be using the
default value (5 seconds), so this is more about being future proof.