1590 Commits

Author SHA1 Message Date
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
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
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
Linus Torvalds
f107d7c0d8 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*.

[Jef Driesen: Renamed the backend to uwatec, and made some smaller
              cosmetic changes to match the existing coding style.]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-28 15:32:39 +02:00
Jef Driesen
434e765128 Merge branch 'ix3m' 2017-06-16 09:00:26 +02:00
Jef Driesen
24621ed519 Improve the handling of unreadable dives
Dives that are reported by the dive computer as unreadable (for example
due to a power loss during the dive) are now skipped instead of being
reported as a fatal error. Those dives can't be retrieved, so there is
no good reason to abort the download.
2017-06-16 08:57:02 +02:00
Jef Driesen
3b967f9eb1 Improve the handling of devices without any dives
Don't return an error if the dive computer reports there are no dives
available!
2017-06-16 08:57:00 +02:00
Jef Driesen
5178c0f755 Add extra NAK error codes 2017-06-16 08:56:02 +02:00
Jef Driesen
35d1e6ff14 Propagate the error code to the caller 2017-06-16 08:09:32 +02:00
Jef Driesen
31c68ba338 Automatically re-transmit corrupt data packets
Originally packets are only retried when a valid NAK packet with the
busy error code is received. The retrying is now enabled for other types
of errors also, such as data packets with checksum errors.
2017-06-14 16:36:40 +02:00
Jef Driesen
37392a03f2 Add a separate transport type for USB HID 2017-06-02 12:11:39 +02:00
Jef Driesen
58eebf4ece Add a bluetooth transport type 2017-06-02 12:11:39 +02:00
Jef Driesen
3c7bd525bb Add support for native bluetooth communication
For the time being, the bluetooth communication code is of very limited
use. It's not used anywhere in the library, and as an internal api it's
also not available to applications. It serves mainly as a reference
implementation for future use.

The implementation supports Windows and Linux.
2017-06-02 12:11:39 +02:00
Jef Driesen
404cea7417 Move the dummy IrDA implementation
The dummy IrDA implementation is integrated in the main file. The
appropriate implementation is selected using conditional compilation
based on the features detect by the autotools build system.
2017-06-02 12:11:39 +02:00
Kristaps Dzonsons
0b22a2ba33 Fix the Oceanic OCS freedive mode 2017-06-02 11:24:00 +02:00
Jef Driesen
4545730776 Report the average ppO2 in external O2 sensor mode only
Just like the ppO2 values from the O2 sensors, the average ppO2 should
be reported in external O2 sensor mode only.
2017-05-27 22:33:22 +02:00
John Van Ostrand
344bfab229 Altered model detection after seeing some bytes change after a firmware update. 2017-05-27 21:37:15 +02:00
Jef Driesen
e2d623fc65 Merge branch 'ix3m' 2017-05-24 07:18:19 +02:00