Subsurface Mobile: Adding mares USB (cp210x) support; how to proceed
Christof Arnosti
charno at charno.ch
Sun Mar 1 10:32:02 PST 2020
Hi together,
Soo... I own a Mares Puck Pro, and I want to use Subsurface Mobile to
transfer dives from the computer.
I found that currently for android a libftdi / libusb-based driver
(serial_ftdi.{c,h}) is available for FTDI based serial converters. The
Mares USB cable uses a cp210x based converter.
In the FAQ at subsurface-divelog.org I found the following paragraph:
"Subsurface-mobile on Android and dive computers with FTDI download cables
Subsurface-mobile on Android (but not on iOS beacuse of hardware
limitations) is designed to be able to download from some dive computers
using FTDI based download cables and a USB OTG adapter. Unfortunately,
there is an issue with the way in which Subsurface-mobile opens USB
devices on Android. We do this from “native code”, not from a Java
application. And while many Android phones allow this method of
accessing OTG devices, an (apparently increasing) number of devices
don’t. On these Android devices the attempt to download from
divecomputers via the USB OTG adapter always fails. We understand in
theory how to work around this problem, but haven’t found the right
developer who could volunteer their time to help us fix the issue."
Well... Maybe I want to be this person, and for sure I want to be the
person to add cp210x support. I would be glad if somebody could explain
what the proposed workaround mentioned in the paragraph would be?
While recherching I found the git repo
https://github.com/mik3y/usb-serial-for-android containing a collection
of USB serial converter drivers for android. The drivers are licensed as
LGPL2.1 (GPL compatible) and are written in Java using the Android USB
Host API.
>From the code that I have read I have two possible ways to go forward:
First (my preferred way):
Directly use the java code from usb-serial-for-android, write a small
abstraction class in java to provide a convenient interface, and a small
class in c to call the java abstraction class (similar to what
serial_ftdi does with libftdi).
Pros:
- This could act as a generic way to access USB serial-based
divecomputers, including FTDI ones.
- Using the official Android USB Host API means that the chance for
support on different phones is quite high.
Cons:
- More Platform-Specific, non-C code.
Second:
Translate the CP210x driver from usb-serial-for-android to C code using
libusb.
Pros:
- C-Code
Cons:
- More work
- Chipset-Specific
What do you think about this two possibilities? I would prefer to
directly use usb-serial-for-android, since for the desktop application
there is already existing support for the different USB-Serial chipsets,
so portability of the code for non-android builds is not that important
in my eyes. With this subsurface would also only need one
android-specific driver implementation for different chipsets.
I would love to hear your toughts and maybe get some additional pointers
I could use while developing. I would mainly work on the task in the
next week, since I have holidays and the event I wanted to go to was
canceled due to the corona virus.
Best regards
Christof
More information about the subsurface
mailing list