1432 Commits

Author SHA1 Message Date
Linus Torvalds
b04f393b97 Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
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
v4.6.4
2017-04-12 08:24:04 -07:00
Jan Mulder
84eb59c3ce Prevent buffer overrun
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>
2017-04-12 12:45:17 +02:00
Jef Driesen
d021bb98ef Disable the deco events
These deco events have already been converted to a deco sample.
2017-04-08 08:56:15 +02:00
Jef Driesen
bfd7301945 Replace the deco events with a deco sample 2017-04-08 08:56:15 +02:00
Jef Driesen
e2c020d4c7 Report errors from the close function 2017-04-08 08:46:07 +02:00
Jef Driesen
0609a4c80a Mark the private function as static 2017-03-30 15:09:40 +02:00
Jef Driesen
c5d5220e28 Fix a bug in the tank pressure samples
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.
2017-03-28 13:12:19 +02:00
Jef Driesen
640308c076 Disable freedive mode for the Uwatec Aladin Tec 2G
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.
2017-03-27 21:36:11 +02:00
Jef Driesen
b1ba3fa0c6 Mark the private function as static 2017-03-27 16:23:23 +02:00
Jef Driesen
c5fac27bc8 Fix some compiler warnings 2017-03-08 08:54:42 +01:00
Jef Driesen
57ffb2ba7a Fix some more null pointer dereferences 2017-03-08 08:47:04 +01:00
Jef Driesen
8735071fac Use a more efficient download algorithm
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.
2017-02-27 08:20:49 +01:00
Jef Driesen
2646e4df86 Use the new ringbuffer stream
All dive computer backends are updated to use the new ringbuffer stream.
2017-02-16 21:04:59 +01:00
Jef Driesen
3f82a553bd Add a common ringbuffer reading algorithm
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.
2017-02-16 20:34:09 +01:00
Jef Driesen
f83d156fdb Improve the robustness of the IrDA I/O code
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.
2017-02-16 13:11:14 +01:00
Jef Driesen
24cbff9a9f Fix a few null pointer dereferences 2017-02-16 12:00:41 +01:00
Jef Driesen
e96611cccd Fix the number of gas mixes
The Tusa Zen supports a maximum of only 2 gas mixes.
2017-02-10 19:42:02 +01:00
Jef Driesen
3f9133def9 Always use the sample timestamp as the base value
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.
2017-02-08 07:43:44 +01:00
Dirk Hohndel
ca04147126 Merge pull request #2 from torvalds/upstream-from-jef
Pull upstream updates from jef
v4.6.3 v4.6.2 v4.6.1
2017-02-01 21:49:21 -08:00
Jef Driesen
0832f97492 Fix the name of the Aqualung i550
The Aqualung i550 doesn't have a "T" (which probably stands for
transmitter) in its name.
2017-02-01 08:32:01 +01:00
Jef Driesen
9cb6856bfb Fix the ndl/deco and rbt samples
The Air Time Remaining (ATR) and Dive Time Remaining (DTR) fields have
been swapped.
2017-01-30 20:54:59 +01:00
Jef Driesen
ae954af768 Parse the sample interval correctly
The Cressi Drake supports a sample interval of 1, 2, 3 and 4 seconds.
2017-01-23 08:40:00 +01:00
Jef Driesen
7b589cab9d Merge branch 'i450t' 2017-01-19 22:12:17 +01:00
Jef Driesen
e5805f3f7d Fix the Aqualung i450T time samples
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.
2017-01-19 22:11:48 +01:00
Jef Driesen
8a4c1f1ef7 Split the raw data into multiple vendor samples
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.
2017-01-19 22:11:48 +01:00
Jef Driesen
7c0f8f9b9d Output samples only once all raw data is available
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.
2017-01-19 22:06:52 +01:00
Jef Driesen
0429ea146e Fix the length check 2017-01-19 22:06:31 +01:00
Jef Driesen
ef47084e05 Skip the extra samples one by one
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.
2017-01-19 22:06:31 +01:00
Jef Driesen
ef1e64ac03 Fix the memory layout for the Hollis DG03
The profile ringbuffer ends at 0xFE00 instead of 0x10000.
2017-01-19 22:05:20 +01:00
Jef Driesen
3c17132a55 Implement ndl/deco for the Hollis DG03 2017-01-19 22:05:20 +01:00
Linus Torvalds
71cf0a5c69 Merge branch 'master' of git://git.libdivecomputer.org/libdivecomputer into sync-with-upstream
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.
  ...
2017-01-16 16:01:10 -08:00
Kristaps Dzonsons
6c356604ec Document the date/time functions 2017-01-12 19:03:28 +01:00
Anton Lundin
3f74840f4c Fix bug in ostc deco info string parsing
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>
v4.6.0
2017-01-08 14:16:17 -08:00
Anton Lundin
2e650b68ae Teach ostc deco model info strings about OSTC4 VPM
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-08 13:49:06 -08:00
Anton Lundin
6fccf5923f Correct shearwater Deco model info string
The literal % where in the wrong place.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-08 13:49:06 -08:00
Anton Lundin
a6421b2f7b Correct firmware string for OSTC4
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>
2017-01-08 11:54:49 -08:00
Anton Lundin
19b560d9b2 Fix logging of Custom Write
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>
2017-01-08 11:54:49 -08:00
Kristaps Dzonsons
77b0cebb35 Document the public api with man pages 2017-01-07 13:41:07 +01:00
Jef Driesen
07dcc8998b Add support for the Cressi Drake
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.
2016-12-30 22:25:14 +01:00
Jef Driesen
3dbfe9d66d Detect overwritten dive profiles
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.
2016-12-30 10:01:39 +01:00
Jef Driesen
8c71aebe45 Merge branch 'iconhd' 2016-12-23 20:38:49 +01:00
Jef Driesen
7c7c62dab2 Ignore tank pressure if no sensor is attached
If no tank pressure sensor is attached, the extra 8 bytes with the tank
info are still present, but the recorded tank pressure value is always
zero.
2016-12-23 20:00:05 +01:00
Jef Driesen
f74e354d68 Add support for the tank field 2016-12-23 19:50:13 +01:00
Jef Driesen
9d95870f78 Add support for the salinity field 2016-12-21 10:20:11 +01:00
Jef Driesen
8c95180578 Use the sample interval from the settings
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.
2016-12-21 10:08:04 +01:00
Jef Driesen
296b13947f Update the Aqualung i750TC parser
The Aqualung i750TC data format appears identical to the Oceanic VTX
format. Therefore the i750TC parser is updated to match with the VTX
parser.
2016-12-06 08:47:11 +01:00
Jef Driesen
7778533bdf Toggle the DTR line during setup
On linux, several users are reporting download problems, while on
windows everything works fine. Simply toggling the DTR line appears to
fix the problem.

A possible explanation is that on windows, the SetCommState() function
not only configures the serial protocol parameters, but also initializes
the DTR and RTS lines. In the libdivecomputer implementation the default
state is enabled (DTR_CONTROL_ENABLE and RTS_CONTROL_ENABLE). The result
is that the DTR line gets automatically initialized to enabled, and then
manually disabled again.

On linux, the DTR and RTS lines are not automatically initialized during
configuration, and need to be controlled explicitely. The result is that
the DTR line ends up disabled without being toggled.
2016-11-29 10:14:28 +01:00
Jef Driesen
c3dc368163 Implement the read function
The read command appears to be limited to the range 0x1000-0x1100. That
range seems to correspond with the first 256 bytes of the full memory
dump. The packet size of 32 bytes is an arbitrary choice.
2016-11-29 08:54:30 +01:00
Ryan McLean
39aa859d19 Add doxygen documentation to the build system 2016-11-22 20:25:50 +01:00
Jef Driesen
61f3031364 Add support for the Aqualung i750TC 2016-11-12 16:05:50 +01:00