From 428704b538c2ee7c7e7448e5180d4f52600d6170 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 13 Nov 2017 09:30:41 +0100 Subject: [PATCH] Add support for the Scubapro Aladin Square The communication protocol is identical to the G2 protocol, but with a different USB VID/PID (c251:2006). Note that unlike the G2, the Aladin Square seems to support only 33 byte USB HID packets (1 byte report id and 32 bytes payload), even when the actual command is much smaller. Without padding the commands, the dive computer doesn't reply at all. Because the padding is already there, to support the Windows api, no further changes are necessary. --- src/descriptor.c | 1 + src/device.c | 2 +- src/uwatec_g2.c | 14 ++++++++++++-- src/uwatec_g2.h | 2 +- src/uwatec_smart_parser.c | 8 ++++++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/descriptor.c b/src/descriptor.c index 6a2d695..52186f4 100644 --- a/src/descriptor.c +++ b/src/descriptor.c @@ -139,6 +139,7 @@ static const dc_descriptor_t g_descriptors[] = { /* Scubapro G2 */ #ifdef USBHID {"Scubapro", "Aladin Sport Matrix", DC_FAMILY_UWATEC_G2, 0x17}, + {"Scubapro", "Aladin Square", DC_FAMILY_UWATEC_G2, 0x22}, {"Scubapro", "G2", DC_FAMILY_UWATEC_G2, 0x32}, #endif /* Reefnet */ diff --git a/src/device.c b/src/device.c index 6277c90..349ed1d 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 = uwatec_g2_device_open (&device, context); + rc = uwatec_g2_device_open (&device, context, dc_descriptor_get_model (descriptor)); break; case DC_FAMILY_REEFNET_SENSUS: rc = reefnet_sensus_device_open (&device, context, name); diff --git a/src/uwatec_g2.c b/src/uwatec_g2.c index 4ef949f..5f62f4b 100644 --- a/src/uwatec_g2.c +++ b/src/uwatec_g2.c @@ -35,6 +35,8 @@ #define RX_PACKET_SIZE 64 #define TX_PACKET_SIZE 32 +#define ALADINSQUARE 0x22 + typedef struct uwatec_g2_device_t { dc_device_t base; dc_usbhid_t *usbhid; @@ -178,7 +180,7 @@ uwatec_g2_handshake (uwatec_g2_device_t *device) dc_status_t -uwatec_g2_device_open (dc_device_t **out, dc_context_t *context) +uwatec_g2_device_open (dc_device_t **out, dc_context_t *context, unsigned int model) { dc_status_t status = DC_STATUS_SUCCESS; uwatec_g2_device_t *device = NULL; @@ -200,7 +202,15 @@ uwatec_g2_device_open (dc_device_t **out, dc_context_t *context) device->devtime = 0; // Open the irda socket. - status = dc_usbhid_open (&device->usbhid, context, 0x2e6c, 0x3201); + unsigned int vid = 0, pid = 0; + if (model == ALADINSQUARE) { + vid = 0xc251; + pid = 0x2006; + } else { + vid = 0x2e6c; + pid = 0x3201; + } + status = dc_usbhid_open (&device->usbhid, context, vid, pid); if (status != DC_STATUS_SUCCESS) { ERROR (context, "Failed to open USB device"); goto error_free; diff --git a/src/uwatec_g2.h b/src/uwatec_g2.h index c7ac7ca..801e15d 100644 --- a/src/uwatec_g2.h +++ b/src/uwatec_g2.h @@ -31,7 +31,7 @@ extern "C" { #endif /* __cplusplus */ dc_status_t -uwatec_g2_device_open (dc_device_t **device, dc_context_t *context); +uwatec_g2_device_open (dc_device_t **device, dc_context_t *context, unsigned int model); #ifdef __cplusplus } diff --git a/src/uwatec_smart_parser.c b/src/uwatec_smart_parser.c index e0726e4..a70acb7 100644 --- a/src/uwatec_smart_parser.c +++ b/src/uwatec_smart_parser.c @@ -46,6 +46,7 @@ #define GALILEOTRIMIX 0x19 #define SMARTZ 0x1C #define MERIDIAN 0x20 +#define ALADINSQUARE 0x22 #define CHROMIS 0x24 #define MANTIS2 0x26 #define G2 0x32 @@ -522,7 +523,8 @@ 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 == ALADINSPORTMATRIX) { + parser->model == G2 || parser->model == ALADINSPORTMATRIX || + parser->model == ALADINSQUARE) { unsigned int offset = header->tankpressure + 2 * i; endpressure = array_uint16_le(data + offset); beginpressure = array_uint16_le(data + offset + 2 * header->ngases); @@ -600,6 +602,7 @@ uwatec_smart_parser_create (dc_parser_t **out, dc_context_t *context, unsigned i case MERIDIAN: case CHROMIS: case MANTIS2: + case ALADINSQUARE: parser->headersize = 152; parser->header = &uwatec_smart_galileo_header; parser->samples = uwatec_smart_galileo_samples; @@ -952,7 +955,8 @@ 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 == ALADINSPORTMATRIX) { + parser->model == G2 || parser->model == ALADINSPORTMATRIX || + parser->model == ALADINSQUARE) { // Uwatec Galileo id = uwatec_galileo_identify (data[offset]); } else {