this looks suspiciously easy

Jef Driesen jef at libdivecomputer.org
Thu Apr 19 00:18:34 PDT 2018


On 2018-04-19 08:40, Dirk Hohndel wrote:
> On Wed, Apr 18, 2018 at 11:37:53PM -0700, Dirk Hohndel wrote:
>> On Thu, Apr 19, 2018 at 08:13:23AM +0200, Jef Driesen wrote:
>> >
>> > You can also get the mask with the built-in transports from libdivecomputer
>> > with the dc_context_get_transports() function. With the above, you'll for
>> > example show usb or usbhid devices even when libdivecomputer was build
>> > without usb or usbhid support.
>> >
>> > For transports where subsurface uses a custom I/O implementation (bluetooth
>> > and ble), you of course need to set the bits as above.
>> 
>> Cool - that's even better.
>> Of course I first wondered... darn, where do I get the context from in
>> this part of my code. Then I looked at the sources of 
>> libdivecomputer...
>> 
>> unsigned int
>> dc_context_get_transports (dc_context_t *context)
>> {
>>         UNUSED(context);
>> 
>>         return DC_TRANSPORT_SERIAL
>> #if defined(HAVE_LIBUSB)
>>                 | DC_TRANSPORT_USB
>> #endif
>> ...
>> 
>> OK, I guess I'll just pass in a NULL pointer :-)

That should be fine. I only added the context pointer in case we ever 
need it in the future. I doubt that will ever be necessary, but it was 
easier to add now then having to change it later.

> ... aaaaand of course... since it ALWAYS adds in the 
> DC_TRANSPORT_SERIAL
> flag, I guess I have to mask that back out on iOS where we don't 
> actually
> have support for serial dive computers...

Yeah, that's indeed an annoying special case. The code builds just fine 
and probably works too, but without any usb-serial drivers (or even the 
ability to connect those devices) you can't really do much with it.

Jef


More information about the subsurface mailing list