1636 Commits

Author SHA1 Message Date
Jef Driesen
133b7394c2 Rename the OSTC 3+ to OSTC Plus
The correct name for the OSTC 3+ is OSTC Plus nowadays. Allthough the
exact name doesn't really matter because all OSTC3 based models are
compatible, using the correct name should reduce confusing for
end-users.
2017-08-17 08:46:35 +02:00
Jef Driesen
2813d61f65 Locate the most recent dive using the logbook pointers
I received a bug report from a device which failed to download new dives
after a reset (probably caused by an empty battery). This reset appears
to reset the internal dive counter back to zero, and also resets the
write pointer back to the begin of the logbook ringbuffer, but leaves
the existing logbook entries in place. The result is that the logic to
find the most recent dive based on the highest internal dive counter,
will be wrong because it finds those old entries.

The discovery of the logbook (and profile) write pointers eliminates the
need to search for the most recent logbook entry.
2017-08-15 23:29:30 +02:00
Jef Driesen
f7bcbb5828 Add support for the Aqualung i200 2017-08-15 11:47:05 +02:00
Jef Driesen
813400ec54 Merge branch 'cochran' 2017-08-15 11:39:32 +02:00
John Van Ostrand
cdf7e8e635 Add event handling to TM model
For some reason I had never added event processing to this model.
2017-08-15 11:30:13 +02:00
John Van Ostrand
3f1131f80f Fix profile buffer size and address size
I dived the model enough to wrap the profile buffer and I was wrong
about where the end was. Also, the buffer starts 3 bytes after where it
could. We were treating profile pointers as 4 bytes when they are two
bytes. This worked most of the time when short tissues were clear
(tissue load follows the pointer).
2017-08-15 11:30:09 +02:00
John Van Ostrand
adef3f67fc Add three event codes
I found three previously undiscovered event codes.
2017-08-15 11:30:04 +02:00
John Van Ostrand
fb65726a55 Add support for the Commander TM
The Cochran Commander TM appears to be a first generation Commander with
limited storage and function compared to later models.

The main differences are:

 - The TM doesn't support high-speed transfer so use the 0x05 read
   command and don't change to a higher baud rate. Still reset to 9600
   to wait for the heartbeat.
 - The TM has a different config command (one byte).
 - The TM has only one config page.
2017-08-15 11:29:58 +02:00
John Van Ostrand
1d8f25ba9b Dump function no longer assumes reads begin at byte 0
For previously supported Cochran computers high-speed read of log and
profile data started at byte 0. Older models that lack the high-speed
transfer function use the standard speed read commands and so the log
and profile data are read at higher addresses.
2017-08-15 11:29:40 +02:00
John Van Ostrand
8b41e72cf7 Remove unneeded function
Since moving to per-dive download of profile data (and now rbstream
download) the data->sample_data_offset and data->sample_size variables
aren't used so calculating them doesn't make sense.
2017-08-15 11:29:05 +02:00
Jef Driesen
88b6e36e04 Use only a single read operation
The profile and throw-away data can be read all at once. This avoids the
need for an extra memory allocation and fixes a memory leak.
2017-08-15 11:28:57 +02:00
John Van Ostrand
cd5eb61e90 Make rbstream pagesize smaller and device specific
The progress bar was taking 18 seconds between updates on a Commander II
when using a 128K pagesize. Since devices differ in their baud rates, it
makes sense to use smaller pages on slower devices. This change reduces
it to 32K on a Commander II and to 64K on EMC devices.
2017-08-15 11:28:19 +02:00
John Van Ostrand
55e8f83eb5 Use rbstream for reading profile data
Per-dive reading of the DC takes too long because of latency on read
commands. The rbstream solves this by reading ahead in large blocks.
2017-08-15 11:28:09 +02:00
Jef Driesen
4e0c2e4650 Remove non-existing function from header
The dc_device_version() function has been removed from the public api
long time ago.
2017-08-11 08:22:53 +02:00
Jef Driesen
535d612a93 Use the correct type in the leonardo vtable 2017-08-02 09:19:03 +02:00
Linus Torvalds
9fd6635cf6 Merge branch 'master' of git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge with upstream libdivecomputer from Jef:

 - Jef merged my Scubapro G2 work, but renamed everything, and didn't
   get the newer IO model code. Very annoying.

   I went along with changing the G2 model family name to
   DC_FAMILY_UWATEC_G2 just to keep some of the basic infrastructure
   more easily mergeable.  But his uwatec_g2 version is not usable.

 - Cochran updates from John Van Ostrand

 - Misc improvements from Jef:
    * divesystems idive improvements
    * Oceanic OCS freedive mode
    * ppO2 callback cleanup

 - Some transport type work:
    * changes to IRDA configuration
    * basic bluetooth rfcomm transport mode

* 'master' of git://git.libdivecomputer.org/libdivecomputer: (35 commits)
  Removed unused code
  Fixed duplicate gasmix event reports
  Added decompression event handling for the Commander
  Fix bad profiles when profile ringbuffer wraps around
  Changed cochran_comander_profile_size function parameters
  Fixed location and encoding of Commander II pointers
  Use a local variable for the layout pointer
  Add new EMC device model string
  Add support for Pre-21000 s/n Commander dive computers
  Fix problems with wrapped logbook ringbuffer
  Retry read operations on failure
  Change profile download to be incremental
  Fix the id string offset
  Fix the progress events
  Use the trimix data format
  Use the correct model number
  Enable more fine grained progress events
  Abort with an error if the buffer is too small
  Use the standard libdivecomputer error codes
  Scubapro G2: add missed command packet logging
  ...
2017-07-10 14:00:47 -07:00
Linus Torvalds
eed75cb0be Clean up Shearwater string handling
And remove the nasty and disgusting transmitter data handling code that
Dirk added to work around his misunderstanding of the parsing code.

This code now collects the various states of the transmitter batteries
throughout a dive and reports the most meaningful summary in the end. It
also rewrites the rest of the string handling code to be architecturally
cleaner.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09 14:36:05 -07:00
Dirk Hohndel
4a3f7a7cce Mark DC descriptors with supported transport
The syntax is trivial.
"// FTDI" for FTDI cable support
"// BT"   for classic Bluetooth support
"// BLE"  for Bluetooth LE support

We can then parse this information during the Subsurface build process
and create the (hopefully correct) support matrix for dive computer
download from the mobile apps.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-08 15:25:22 -07:00
Dirk Hohndel
8ea8cebb4e Shearwater: correctly handle the different models
That weird 'petrel' argument and member variable can easily be replaced
by looking at the model.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 18:00:54 -07:00
Dirk Hohndel
6f4776d6c4 Shearwater: detect the hardware type
Stop pretending that all the devices since the Petrel are the same. They
actually aren't. So let's detect them and correctly identify them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 17:29:41 -07:00
Dirk Hohndel
04073759a8 Shearwater: add transmitter battery information
This should be a STRING callback, but those come from the header and we
don't have the information until after we have parsed all the samples.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 16:36:50 -07:00
Dirk Hohndel
84ad5aa5ad Shearwater: report battery type for logversion >= 7
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 16:36:50 -07:00
Dirk Hohndel
41417fbe59 Shearwater: add support for remaining gas time
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 16:36:50 -07:00
Dirk Hohndel
8736a6dca1 Shearwater: extract tank sensor data for log version 7
The first dive computer to support this is the Perdix AI. Interestingly,
this keeps track of two sensors at all times. I haven't seen data with
two sensors active, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 09:54:50 -07:00
Dirk Hohndel
d85481cefd Shearwater: extrac log version from header
The earliest document I have references log version 6. There are
apparently older versions, but I don't know what the differences
are. Before version 7, the log version wasn't always reliably
stored, so we assume 6 is the minimum and use 7 (or later) if we
find it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 07:04:13 -07:00
Jef Driesen
b8b94c46fc Merge branch 'cochran' 2017-07-05 13:12:27 +02:00
John Van Ostrand
fd1557f634 Removed unused code 2017-07-05 13:11:33 +02:00
John Van Ostrand
2c5e787b77 Fixed duplicate gasmix event reports
Newer cochran DCs record a gas change event at the begining of a
dive. The code creates a gas change before processing samples so
with newer DCs this resulted in duplicate events.
2017-07-05 13:11:33 +02:00
John Van Ostrand
094b635f87 Added decompression event handling for the Commander
I finally found an example of decompression on a Commander II computer
and it seems to be identical to the EMC.
2017-07-05 13:11:33 +02:00
John Van Ostrand
e1b679912a Fix bad profiles when profile ringbuffer wraps around
The method used to calculate the data used by dives (to determine when
we run out of ringbuffer) incorrectly didn't include surface sample
data. Ten to twenty minute of sample data is recorded at the surface in
case the diver re-descends, continuing the dive. The code then thought
that older dive profiles were not yet overwritten. The improper data was
returned to the user.
2017-07-05 13:11:33 +02:00
John Van Ostrand
9c795e6e4e Changed cochran_comander_profile_size function parameters
This function is much more useful if it works like a
ringbuffer_distance() function. It assumed the wrong values when
calculating profile size and it didn't have easy access to values it
needed to properly calculate profile sizes.

It makes sense to keep since it validates pointers.
2017-07-05 13:11:33 +02:00
John Van Ostrand
48d93e9404 Fixed location and encoding of Commander II pointers
Commander II pointers to profile ringbuffer data was wrong. After seeing
the Commander I encoding I realized the Commander II encoding of RB
pointers was in a flipped word big endian format. It only appeared to be
in normal big endian format because of an adjacent pointer that usually
shared the same first two bytes.
2017-07-05 13:11:33 +02:00
John Van Ostrand
3545bf158a Use a local variable for the layout pointer 2017-07-05 13:11:33 +02:00
John Van Ostrand
3a2f2ff0c3 Add new EMC device model string 2017-07-05 13:11:33 +02:00
John Van Ostrand
216e393f43 Add support for Pre-21000 s/n Commander dive computers
This adds support for older Cochran Commander dive computers,
specifically Commanders with serial numbers prior to 21000.

This also renames "Commander" model to "Commander II" and
adds "Commander I" to refer to pre-21000 models.
2017-07-05 13:11:33 +02:00
John Van Ostrand
45f0605678 Fix problems with wrapped logbook ringbuffer 2017-07-05 13:11:33 +02:00
John Van Ostrand
b3d2c603dd Retry read operations on failure
[Jef Driesen: Modified to retry only for non-fatal errors.]
2017-07-05 13:07:36 +02:00
John Van Ostrand
346391ae2c Change profile download to be incremental
It will result in a 30 minute download for full computers but it
significantly reduces the time to download partial dives.
2017-07-05 09:15:05 +02:00
Jef Driesen
c26755624d Fix the id string offset
Since commit 344bfab229a17c7227b9bec02f616505a8d9e998 only a subset of
the id string is used to detect the model. But because the offset was
never updated, the model detection always fails now.
2017-07-05 09:15:05 +02:00
Jef Driesen
7ce057d2ba Fix the progress events
I accidentally passed the address of the progress pointer to the
device_event_emit() function, instead of the pointer itself. Oops.
2017-07-04 14:58:52 +02:00
Linus Torvalds
0143be5497 Fix incorrect placement of -lz (zlib) in autotools build
When I added support for the new Suunto EON Steel bluetooth download, I
needed crc32(), and instead of cooking my own (libdivecomputer does do
its own versions of the simpler crc functions), I made libdivecomputer
just depend on zlib instead, which provides a convenient crc32() function.

But I didn't add the new linker flag (-lz) in the right place in the
automake.  It worked fine for me on Linux, but apparently not so well on
macos.

This fixes it.

Reported-and-tested-by: Benjamin <nystire@gmail.com>
Tested-by: Axel Richter <Axel.Richter@freenet.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-28 13:04:24 -07:00
Jef Driesen
cdcfef6c1a Merge branch 'g2' 2017-06-28 15:33:57 +02:00
Jef Driesen
3a05e0ecf0 Use the trimix data format 2017-06-28 15:32:39 +02:00
Jef Driesen
0a5623a949 Use the correct model number
The model number reported by the Scubapro G2 is 0x32.
2017-06-28 15:32:39 +02:00
Jef Driesen
7ee210f83f Enable more fine grained progress events
At the moment, the progress reporting will jump straight from about 0%
at the start of the download to 100% at the end of the download, without
any updates in between. This is improved by updating after every packet.
2017-06-28 15:32:39 +02:00
Jef Driesen
06259fed19 Abort with an error if the buffer is too small
Silently truncating the data packet if the buffer is too small will
result in a corrupt data stream.
2017-06-28 15:32:39 +02:00
Jef Driesen
eae071c97d Use the standard libdivecomputer error codes
The error code returned by the dc_usbhid_read() function should be
returned as-is, instead of being replaced with some generic error, which
gets translated again to DC_STATUS_IO in the caller.
2017-06-28 15:32:39 +02:00
Linus Torvalds
fcfee82cc8 Scubapro G2: add missed command packet logging
I did the packet logging for the received data side, but forgot to do
the same thing on the command transfer side, which makes the debug logs
a bit less useful.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-28 15:32:39 +02:00
Linus Torvalds
8c0ab03706 Scubapro G2: add back the initial handshake code
When doing the G2 downloader, I dropped the initial handshake as I tried
to keep the code minimal, and the handshake didn't seem to make any
difference what-so-ever to me.

And it probably doesn't matter for anybody else either.  But the code
isn't working for some people, and maybe it does actually matter.

More importantly, Scubapro's own LogTRAK application does send those two
initial commands, and it's probably a good idea to minimize the
differences between the different downloaders anyway, so add the
handshake sequence back in.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-28 15:32:39 +02:00
Linus Torvalds
4ef57b24bb 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-28 15:32:39 +02:00