From d2643496769e0bb46014f6e1bf1767817e3781cb Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 25 Apr 2018 12:53:48 -0700 Subject: [PATCH] Re-instate the lack of handshaking for the Scubapro Aladin Sport Matrix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I thought this wasn't needed any more (incorrectly thinking that Jef had knowledge we didn't - he had merged the other changes), and had just taken Jef's version of the code. Berthold Stöger tells me otherwise. The Aladin Sport Matrix returns 0 instead of 1 to the initial handshake, and makes libdivecomputer unhappy. This just skips the handshake entirely for the Sport Matrix, since apparently LogTrak doesn't do any either. See also commit 8a84ece7d0ef ("Support for the Scubapro Aladin Sport Matrix") in our old Subsurface branch. Reported-by: Berthold Stöger Signed-off-by: Linus Torvalds --- src/uwatec_g2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/uwatec_g2.c b/src/uwatec_g2.c index 798cc9a..c8e7894 100644 --- a/src/uwatec_g2.c +++ b/src/uwatec_g2.c @@ -34,7 +34,9 @@ #define RX_PACKET_SIZE 64 #define TX_PACKET_SIZE 32 +#define ALADINSPORTMATRIX 0x17 #define ALADINSQUARE 0x22 +#define G2 0x32 typedef struct uwatec_g2_device_t { dc_device_t base; @@ -150,7 +152,7 @@ uwatec_g2_transfer (uwatec_g2_device_t *device, const unsigned char command[], u static dc_status_t -uwatec_g2_handshake (uwatec_g2_device_t *device) +uwatec_g2_handshake (uwatec_g2_device_t *device, unsigned int model) { dc_device_t *abstract = (dc_device_t *) device; @@ -158,6 +160,11 @@ uwatec_g2_handshake (uwatec_g2_device_t *device) unsigned char answer[1] = {0}; unsigned char command[5] = {0x00, 0x10, 0x27, 0, 0}; + // The vendor software does not do a handshake for the Aladin Sport Matrix, + // so let's not do any either. + if (model == ALADINSPORTMATRIX) + return DC_STATUS_SUCCESS; + // Handshake (stage 1). command[0] = 0x1B; dc_status_t rc = uwatec_g2_transfer (device, command, 1, answer, 1); @@ -209,7 +216,7 @@ uwatec_g2_device_open (dc_device_t **out, dc_context_t *context, dc_iostream_t * device->devtime = 0; // Perform the handshaking. - status = uwatec_g2_handshake (device); + status = uwatec_g2_handshake (device, model); if (status != DC_STATUS_SUCCESS) { ERROR (context, "Failed to handshake with the device."); goto error_free;