From 8a84ece7d0ef380cd228287d8a39ec16bf7c59ec Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 23 Oct 2017 20:55:19 +0200 Subject: [PATCH] Support for the Scubapro Aladin Sport Matrix. The protocol is identical to the G2 protocol, with the exception of a missing handshake. Signed-off-by: Berthold Stoeger Signed-off-by: Linus Torvalds --- src/descriptor.c | 3 ++- src/device.c | 2 +- src/scubapro_g2.c | 13 ++++++++++--- src/scubapro_g2.h | 2 +- src/uwatec_smart_parser.c | 32 +++++++++++++++++--------------- 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/descriptor.c b/src/descriptor.c index a1fa965..b1b6dd1 100644 --- a/src/descriptor.c +++ b/src/descriptor.c @@ -139,7 +139,8 @@ static const dc_descriptor_t g_descriptors[] = { {"Scubapro", "Mantis 2", DC_FAMILY_UWATEC_MERIDIAN, 0x26}, /* Scubapro G2 */ #ifdef USBHID - {"Scubapro", "G2", DC_FAMILY_UWATEC_G2, 0x32}, // BLE + {"Scubapro", "G2", DC_FAMILY_UWATEC_G2, 0x32}, // BLE + {"Scubapro", "Aladin Sport Matrix", DC_FAMILY_UWATEC_G2, 0xa5}, // BLE #endif /* Reefnet */ {"Reefnet", "Sensus", DC_FAMILY_REEFNET_SENSUS, 1}, diff --git a/src/device.c b/src/device.c index 0a9e2ba..35e0951 100644 --- a/src/device.c +++ b/src/device.c @@ -140,7 +140,7 @@ dc_device_open (dc_device_t **out, dc_context_t *context, dc_descriptor_t *descr rc = uwatec_meridian_device_open (&device, context, name); break; case DC_FAMILY_UWATEC_G2: - rc = scubapro_g2_device_open (&device, context, name); + rc = scubapro_g2_device_open (&device, context, name, dc_descriptor_get_model (descriptor)); break; case DC_FAMILY_REEFNET_SENSUS: rc = reefnet_sensus_device_open (&device, context, name); diff --git a/src/scubapro_g2.c b/src/scubapro_g2.c index 6351b69..dc1d221 100644 --- a/src/scubapro_g2.c +++ b/src/scubapro_g2.c @@ -35,6 +35,8 @@ #define RX_PACKET_SIZE 64 #define TX_PACKET_SIZE 32 +#define ALADINSPORTMATRIX 0xa5 + typedef struct scubapro_g2_device_t { dc_device_t base; unsigned int timestamp; @@ -149,7 +151,7 @@ scubapro_g2_transfer(scubapro_g2_device_t *g2, const unsigned char command[], un static dc_status_t -scubapro_g2_handshake (scubapro_g2_device_t *device) +scubapro_g2_handshake (scubapro_g2_device_t *device, unsigned int model) { dc_device_t *abstract = (dc_device_t *) device; @@ -157,6 +159,11 @@ scubapro_g2_handshake (scubapro_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 = scubapro_g2_transfer (device, command, 1, answer, 1); @@ -186,7 +193,7 @@ scubapro_g2_handshake (scubapro_g2_device_t *device) dc_status_t -scubapro_g2_device_open(dc_device_t **out, dc_context_t *context, const char *name) +scubapro_g2_device_open(dc_device_t **out, dc_context_t *context, const char *name, unsigned int model) { dc_status_t status = DC_STATUS_SUCCESS; scubapro_g2_device_t *device = NULL; @@ -219,7 +226,7 @@ scubapro_g2_device_open(dc_device_t **out, dc_context_t *context, const char *na } // Perform the handshaking. - status = scubapro_g2_handshake(device); + status = scubapro_g2_handshake(device, model); if (status != DC_STATUS_SUCCESS) { ERROR (context, "Failed to handshake with the device."); goto error_close; diff --git a/src/scubapro_g2.h b/src/scubapro_g2.h index 43f007a..f960e55 100644 --- a/src/scubapro_g2.h +++ b/src/scubapro_g2.h @@ -31,7 +31,7 @@ extern "C" { #endif /* __cplusplus */ dc_status_t -scubapro_g2_device_open (dc_device_t **device, dc_context_t *context, const char *name); +scubapro_g2_device_open (dc_device_t **device, dc_context_t *context, const char *name, unsigned int model); #ifdef __cplusplus } diff --git a/src/uwatec_smart_parser.c b/src/uwatec_smart_parser.c index 639d0e4..529e623 100644 --- a/src/uwatec_smart_parser.c +++ b/src/uwatec_smart_parser.c @@ -35,19 +35,20 @@ #define NBITS 8 -#define SMARTPRO 0x10 -#define GALILEO 0x11 -#define ALADINTEC 0x12 -#define ALADINTEC2G 0x13 -#define SMARTCOM 0x14 -#define ALADIN2G 0x15 -#define SMARTTEC 0x18 -#define GALILEOTRIMIX 0x19 -#define SMARTZ 0x1C -#define MERIDIAN 0x20 -#define CHROMIS 0x24 -#define MANTIS2 0x26 -#define G2 0x32 +#define SMARTPRO 0x10 +#define GALILEO 0x11 +#define ALADINTEC 0x12 +#define ALADINTEC2G 0x13 +#define SMARTCOM 0x14 +#define ALADIN2G 0x15 +#define SMARTTEC 0x18 +#define GALILEOTRIMIX 0x19 +#define SMARTZ 0x1C +#define MERIDIAN 0x20 +#define CHROMIS 0x24 +#define MANTIS2 0x26 +#define G2 0x32 +#define ALADINSPORTMATRIX 0xa5 #define UNSUPPORTED 0xFFFFFFFF @@ -519,7 +520,7 @@ uwatec_smart_parser_cache (uwatec_smart_parser_t *parser) if (parser->model == GALILEO || parser->model == GALILEOTRIMIX || parser->model == ALADIN2G || parser->model == MERIDIAN || parser->model == CHROMIS || parser->model == MANTIS2 || - parser->model == G2) { + parser->model == G2 || parser->model == ALADINSPORTMATRIX) { unsigned int offset = header->tankpressure + 2 * i; endpressure = array_uint16_le(data + offset); beginpressure = array_uint16_le(data + offset + 2 * header->ngases); @@ -609,6 +610,7 @@ uwatec_smart_parser_create (dc_parser_t **out, dc_context_t *context, unsigned i parser->nevents[2] = C_ARRAY_SIZE (uwatec_smart_galileo_events_2); break; case G2: + case ALADINSPORTMATRIX: parser->headersize = 84; parser->header = &uwatec_smart_trimix_header; parser->samples = uwatec_smart_galileo_samples; @@ -948,7 +950,7 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback if (parser->model == GALILEO || parser->model == GALILEOTRIMIX || parser->model == ALADIN2G || parser->model == MERIDIAN || parser->model == CHROMIS || parser->model == MANTIS2 || - parser->model == G2) { + parser->model == G2 || parser->model == ALADINSPORTMATRIX) { // Uwatec Galileo id = uwatec_galileo_identify (data[offset]); } else {