On 11/08/2020 19:22, Jef Driesen wrote:
Native USB communication (used only by the Atomic Aquatics Cobalt backend) was
not yet ported to the I/O stream interface. This has now changed because I just
pushed a new USB based I/O transport implementation the libdivecomputer master
branch. This means the application is now responsible for setting up the USB I/O
stream, just like all others transports. The Atomic Aquatics Cobalt backend does
no longer open the USB device internally. Passing a NULL pointer for the
iostream will no longer work!
The advantage is that an application can now also use a custom implementation on
platforms where libusb isn't available (iOS) or doesn't work very well due to
permission problems (Android).
Attached is a patch with the necessary changes for subsurface.
Jef
>From 942dd79a26dab21ea980552ef32d9a8e55c26fdd Mon Sep 17 00:00:00 2001
From: Jef Driesen <j...@libdivecomputer.org>
Date: Mon, 10 Aug 2020 20:05:47 +0200
Subject: [PATCH] Setup the USB transport manually
The dive computer backend does no longer setup the USB transport
internally.
Signed-off-by: Jef Driesen <j...@libdivecomputer.org>
---
core/libdivecomputer.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c
index a99d15ae8..4c35a3593 100644
--- a/core/libdivecomputer.c
+++ b/core/libdivecomputer.c
@@ -25,6 +25,7 @@
#include <libdivecomputer/version.h>
#include <libdivecomputer/usbhid.h>
+#include <libdivecomputer/usb.h>
#include <libdivecomputer/serial.h>
#include <libdivecomputer/irda.h>
@@ -1323,10 +1324,24 @@ dc_status_t divecomputer_device_open(device_data_t *data)
}
}
- /* The dive computer backend does this all internally */
if (transports & DC_TRANSPORT_USB) {
- dev_info(data, "Opening native USB device");
- return DC_STATUS_SUCCESS;
+ // Discover the usb device.
+ dc_iterator_t *iterator = NULL;
+ dc_usb_device_t *device = NULL;
+ dc_usb_iterator_new (&iterator, context, descriptor);
+ while (dc_iterator_next (iterator, &device) == DC_STATUS_SUCCESS)
+ break;
+ dc_iterator_free (iterator);
+
+ if (device) {
+ dev_info(data, "Opening USB device for %04x:%04x",
+ dc_usb_device_get_vid(device),
+ dc_usb_device_get_pid(device));
+ rc = dc_usb_open(&data->iostream, context, device);
+ dc_usb_device_free(device);
+ if (rc == DC_STATUS_SUCCESS)
+ return rc;
+ }
}
if (transports & DC_TRANSPORT_SERIAL) {
--
2.25.1
_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface