On 14-11-17 23:04, Linus Torvalds wrote:
On Tue, Nov 14, 2017 at 2:00 PM, vavincavent <vavincav...@gmail.com> wrote:

Now i think it's the analysis of the datas???

Oh, I thought it already worked?

When  you ask subsurface to generate a dump file, it will not actually
import the dives at all.

But now that the communication is working, uncheck that, and see if
the download just works and the dives get imported..

The parsing needs some changes too for the new model number. The attached patch is what I have so far.

Jef
>From 9f18c74c1c576b34ee25591f5c6e999592e1e7ae Mon Sep 17 00:00:00 2001
From: Jef Driesen <jefdrie...@users.sourceforge.net>
Date: Mon, 13 Nov 2017 09:30:41 +0100
Subject: [PATCH] Add support for the Scubapro Aladin Square

---
 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 6a2d6959..52186f44 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 6277c900..349ed1d6 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 4ef949fa..a30c7bda 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 SQUARE            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 == SQUARE) {
+		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 c7ac7ca3..801e15d3 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 e0726e41..e47320c5 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 SQUARE            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 == SQUARE) {
 					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 SQUARE:
 		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 == SQUARE) {
 			// Uwatec Galileo
 			id = uwatec_galileo_identify (data[offset]);
 		} else {
-- 
2.14.1

_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to