1460 Commits

Author SHA1 Message Date
Linus Torvalds
7f21c27b7a Scubapro G2: clean up unused field
Jef Driesen correctly points out that the 'address' field is just
leftover from the IrDA code, and is meaningless for the USB HID
transport version of the Scubapro G2.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-15 06:27:21 +09:00
Linus Torvalds
df9984e123 Add initial Scubapro G2 frontend
The back-end parser seems to be the same as for the Uwatec Smart (aka
Galileo Sol).  At least that's the assumption right now.

The downloader just uses USB HID (very similar to EON Steel) rather than
the horrible IrDA thing.

There's also eventually a BLE thing, but that's for the future.

This is an unholy mixture of the Uwatec Smart downloader logic and the
EON Steel usbhid transfer code.  The back-end is pure Uwatec Smart
(model 0x11, same as Galileo Sol).

I'm not at all sure this gets everything right, but it downloads
*something*.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-08 22:16:14 -07:00
Linus Torvalds
a0c5b5b53b Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge upstream libdivecomputer changes as requested by Jan Mulder.
 "DiveSystem iX3M:
   - Add support for new iX3M models
   - Add support for new iX3M APOS4 firmware
   - Add iX3M firmware version to the devinfo event (ix3m)

  Shearwater:
   - Report the ppO2 in external O2 sensor mode only (Shearwater)
   - Replace the constant offset with a scaling factor (Shearwater)
   - Apply the calibration correction only for the Predator
   - Report individual sensor values
   - Predator: don't report PPO2 unless in CC mode

  Misc:
   - Fix Sherwood Wisdom 3 memory layout
   - Implement read and write functions for OSTC3
   - Add support for Mares Quad
   - Fix uwatec handshaking error handling"

* 'master' of git://git.libdivecomputer.org/libdivecomputer:
  Add support for the new models
  Add support for the new iX3M APOS4 firmware
  Add the firmware version to the devinfo event
  Report the ppO2 in external O2 sensor mode only
  Replace the constant offset with a scaling factor
  Apply the calibration correction only for the Predator
  shearwater: Report individual sensor values
  Predator: don't report PPO2 unless in CC mode
  Fix the Sherwood Wisdom 3 memory layout
  Implement the read and write functions for the OSTC3
  Don't ignore handshaking errors
  Add support for the Mares Quad
2017-05-25 10:26:49 -07:00
Jef Driesen
e2d623fc65 Merge branch 'ix3m' 2017-05-24 07:18:19 +02:00
Jef Driesen
28947876a2 Add support for the new models 2017-05-24 07:18:02 +02:00
Jef Driesen
55b9307e19 Add support for the new iX3M APOS4 firmware
The new APOS4 firmware changed the data format and communication
protocol. The size of the samples changed from 54 to 64 bytes, and in
order to speedup the download, a single data packet contains 3 samples
at once. If the number of samples is not an exact multiple of three, the
last packet appears to contain garbage data.

For parsing, the firmware version is available in the dive header.
Unfortunately it can't be used for dives that are downloaded from a
device with the new firmware, but which have been recorded with an older
firmware. Such dives store the old firmware version in the dive header,
but they also use the new sample format. As a workaround, we inspect the
size of the dive.
2017-05-24 07:18:02 +02:00
Jef Driesen
2854453f26 Add the firmware version to the devinfo event 2017-05-23 09:16:52 +02:00
Jef Driesen
a66da4a45e Merge branch 'shearwater' 2017-05-11 18:21:58 +02:00
Jef Driesen
d6806ab494 Report the ppO2 in external O2 sensor mode only
The O2 sensor millivolt values are only valid if external O2 sensor
monitoring is enabled.

Note that the interpretation of the PPO2 status bit appears to be
reversed (0=external and 1=internal).

Reviewed-by: Anton Lundin <glance@acc.umu.se>
2017-05-11 16:18:43 +02:00
Jef Driesen
7e7cbd55b1 Replace the constant offset with a scaling factor
Correcting the Predator calibration value with a scaling factor produces
even more reasonable ppO2 values compared to using a constant offset.
The scaling factor of 2.2 is based on a linear regression between the
average ppO2 reported by the dive computer, and the average ppO2
calculated over all (calibrated) sensors using the raw calibration
value.

Reviewed-by: Anton Lundin <glance@acc.umu.se>
2017-05-11 16:18:36 +02:00
Jef Driesen
fe2d128b44 Apply the calibration correction only for the Predator
The calibration values for the Petrel are typically in the range 1600 to
2400, while for Predator they are much smaller, with values in the range
800 to 1400. The consequence is that the calculated ppO2 values are too
low for the Predator. Adding a constant offset of about 1000 changes the
calibration value to be in approximately the same range as the Petrel,
and hence more reasonable ppO2 values. But this correction should only
be applied for the Predator, and not the Petrel.

Reviewed-by: Anton Lundin <glance@acc.umu.se>
2017-05-11 16:18:23 +02:00
Anton Lundin
d3ca3e87bd shearwater: Report individual sensor values
This reads the reported mV values from the sensors, and based on the
calibration values converts it into a ppo2 value to report.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-05-11 07:58:03 +02:00
Dirk Hohndel
588e7e7ab4 Predator: don't report PPO2 unless in CC mode
Sending this in OC mode is redundant and might confuse applications that
assume they only get PPO2 data in CC mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-10 11:30:53 +02:00
Jef Driesen
415d7f2214 Fix the Sherwood Wisdom 3 memory layout
The logbook ringbuffer starts at 0x03D0 instead of 0x0240.
2017-05-10 11:16:57 +02:00
Jef Driesen
21c7c9c009 Implement the read and write functions for the OSTC3
The existing infrastructure for upgrading the firmware can also be used
to support reading and writing directly to the internal flash memory.
2017-05-04 08:49:24 +02:00
Jef Driesen
3daba977e0 Don't ignore handshaking errors 2017-05-04 08:34:04 +02:00
Jan Mulder
9df029a704 OSTC3: add battery percentage
From firmware version 2.15, the battery percentage is shown on the
unit (in the logbook that is, it was shown on the display for a very
long time). The used byte in the OSTC3 seems to be populated since
firmware version 2.10. The new percentage data is added to the
"battery at end" voltage data, and a V is added to denote the unit
of the voltage.

In addition, reordered the DC_FIELD_STRINGs a little, so that the
serial is on top.

Further, changed BUFLEN to 32 (as in 84eb59c) due the the length
of the new battery notation.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-04-30 22:10:35 +02:00
Jef Driesen
6e9278ff24 Add support for the Mares Quad 2017-04-30 09:49:15 +02:00
Linus Torvalds
29135bcdf8 Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge upstream libdivecomputer changes from Jef Driesen.

The most noticeable part is Jen Mulder's OSTC3 initial setpoint
addition, which fixes the OSTC3 data in CCR3 mode.

But also various cleanups and fixups from Jef.

* 'master' of git://git.libdivecomputer.org/libdivecomputer:
  OSTC3: set initial setpoint in profile data
  Remove unused parameters
  Cleanup the extract dives functions
  Remove unnecessary helper functions
  Remove deprecated functions from the public api
  Remove unnecessary include statements
  Fix the firmware version and serial number
  Add support for the Uwatec Aladin Tec 3G
2017-04-29 16:37:40 -07:00
Jan Mulder
44f629f03a OSTC3: set initial setpoint in profile data
In CCR fixed setpoint mode of the OSTC3, the initial setpoint at the start
of the dive was not set. This fix adds the initial setpoint based on
the data in the fixed setpoint table (ie, the first fixed setpoint is
the initial one).

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-04-29 10:17:14 +02:00
Jef Driesen
39a7920083 Merge branch 'cleanup' 2017-04-24 13:06:49 +02:00
Jef Driesen
bdf69ce1ec Remove unused parameters 2017-04-24 13:05:20 +02:00
Jef Driesen
468418193b Cleanup the extract dives functions
After being removed from the public api, these functions can be changed
into local, static functions. And in a few cases, they are no longer
necessary and can be removed completely.
2017-04-22 09:11:41 +02:00
Jef Driesen
c5f089b4a6 Remove unnecessary helper functions
The second variant of the open or create functions were introduced to
maintain backwards compatibility. But after being removed from the
public api, these functions serve no purpose anymore, and can be removed
completely.
2017-04-19 11:33:17 +02:00
Jef Driesen
d1a06e784c Remove deprecated functions from the public api
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.
2017-04-18 08:41:10 +02:00
Jef Driesen
8952ad0c29 Remove unnecessary include statements 2017-04-13 08:02:11 +02:00
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
97a6023bb6 Fix the firmware version and serial number
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.
2017-04-12 08:44:10 +02:00
Jef Driesen
9fb7a1f228 Add support for the Uwatec Aladin Tec 3G 2017-04-12 08:35:31 +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