Subsurface Mobile: Adding mares USB (cp210x) support; how to proceed

Christof Arnosti charno at charno.ch
Fri Mar 6 15:23:59 PST 2020


Hi Dirk,

Am 06.03.20 um 23:32 schrieb Dirk Hohndel:
> (oops. I dropped the mailing list by mistake)
>
>> On Mar 6, 2020, at 2:12 PM, Christof Arnosti <charno at charno.ch
>> <mailto:charno at charno.ch>> wrote:
>> Am 06.03.20 um 22:59 schrieb Dirk Hohndel:
>>>
>>>
>>>> On Mar 6, 2020, at 1:54 PM, Christof Arnosti <charno at charno.ch
>>>> <mailto:charno at charno.ch>> wrote:
>>>>> No popup at all as no one has that PID/VID registered. I can simply
>>>>> add the PID/VID and see if it works. I'll play with that later today.
>>>>
>>>> Also try to register the different driver classes in
>>>> https://github.com/charno/subsurface/blob/android-serial-clean/android-mobile/src/org/subsurfacedivelog/mobile/AndroidSerial.java#L92.
>>>> The classes can be found at
>>>> https://github.com/mik3y/usb-serial-for-android/tree/master/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/driver.
>>>
>>> ok
>>>
>>>>>> Can you maybe plug your Mares Icon HD into a computer and give me
>>>>>> some
>>>>>> lsusb and dmesg-output so I can try to guess which vid/pid and
>>>>>> driver is
>>>>>> used?
>>>>> VID/PID is 0xFFFF/0x0005:
>>>>>
>>>>> 03-06 13:39:52.669  1342  1869 D UsbHostManager: USB device
>>>>> attached: vidpid ffff:0005 mfg/product/ver/serial
>>>>> SERUSB/USBSerial/1.00/01234567 hasAudio/HID/Storage: false/false/false
>>>>> 03-06 13:39:52.673  1342  1869 D UsbDeviceDescriptor:   1 configs
>>>>> 03-06 13:39:52.674  1342  1869 D UsbHostManager: Added device
>>>>> UsbDevice[mName=/dev/bus/usb/001/002,mVendorId=65535,mProductId=5,mClass=2,mSubclass=0,mProtocol=0,mManufacturerName=SERUSB,mProductName=USBSerial,mVersion=1.00,mSerialNumberReader=com.android.server.usb.UsbSerialReader at 9967699,mConfigurations=[
>>>>> 03-06 13:39:52.674  1342  1869 D UsbHostManager:
>>>>> UsbConfiguration[mId=2,mName=null,mAttributes=192,mMaxPower=250,mInterfaces=[
>>>>> 03-06 13:39:52.674  1342  1869 D UsbHostManager:
>>>>> UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=2,mSubclass=2,mProtocol=0,mEndpoints=[
>>>>> 03-06 13:39:52.674  1342  1869 D UsbHostManager:
>>>>> UsbEndpoint[mAddress=130,mAttributes=3,mMaxPacketSize=8,mInterval=10]]
>>>>> 03-06 13:39:52.674  1342  1869 D UsbHostManager:
>>>>> UsbInterface[mId=1,mAlternateSetting=0,mName=null,mClass=10,mSubclass=0,mProtocol=0,mEndpoints=[
>>>>> 03-06 13:39:52.674  1342  1869 D UsbHostManager:
>>>>> UsbEndpoint[mAddress=1,mAttributes=2,mMaxPacketSize=64,mInterval=0]
>>>>> 03-06 13:39:52.674  1342  1869 D UsbHostManager:
>>>>> UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=64,mInterval=0]]]]
>>>>>
>>>>>
>>>>> (this is adb logcat over tcp of plugging the Icon HD into my
>>>>> Android phone)
>>>> If you have a linux computer at hand I would be interested which driver
>>>> is used by the kernel. This might give some insight if it's implemented
>>>> in usb-serial-for-android and just not registred, or if the driver is
>>>> missing.
>>>
>>> [2382095.960170] usb 2-1.2: new full-speed USB device number 4 using
>>> ehci-pci
>>> [2382096.041381] usb 2-1.2: New USB device found, idVendor=ffff,
>>> idProduct=0005, bcdDevice= 1.00
>>> [2382096.041388] usb 2-1.2: New USB device strings: Mfr=1,
>>> Product=2, SerialNumber=3
>>> [2382096.041392] usb 2-1.2: Product: USBSerial
>>> [2382096.041395] usb 2-1.2: Manufacturer: SERUSB
>>> [2382096.041398] usb 2-1.2: SerialNumber: 01234567
>>> [2382096.089122] cdc_acm 2-1.2:2.0: ttyACM0: USB ACM device
>>> [2382096.089748] usbcore: registered new interface driver cdc_acm
>>> [2382096.089750] cdc_acm: USB Abstract Control Model driver for USB
>>> modems and ISDN adapters
>>>
>>> This is from a Linux laptop
>>
>> There is a driver with CdcAcmSerialDriver in usb-serial-for-android!
>>
>> That's exactly the use case I had in mind when I proposed
>> driverclass-selection in the UI ;-)
>>
>
> I understand - but Subsurface-mobile would never ever get access to
> this if we don't claim the PID/VID correct?
> That's been my point here... even if you add that driverclass... how
> would Subsurface-mobile get access to that device in the first place?
> Maybe I'm just misunderstanding how this is supposed to work.

If I understand correctly, the device_filter.xml is only necessary to
get the popup which then leads to the download-page.

In the Java code, all devices known to UsbManager are compared by
PID/VID by UsbSerialProber (from usb-serial-for-android). When there's a
match there is a check if we have permission to use this device, and if
not the permission is requested. Then the device is used.

If we do the UsbManager-stuff beforehand to populate the device-list
(and then pass the selecte usb device to Java android_serial_open) we
don't need the UsbSerialProber to check the attached device, but only to
find the correct driver class. If the driver class is also passed to
android_serial_open we can leave out the whole UsbSerialProber-Stuff and
directly instantiate the driver class with the passed usb device. With
all this it's still possible to check and request for permission to
access the device at runtime.

I didn't consciously check for devices not entered in the
device_filter.xml, but I entered "my" PID/VID pair quite late in the
development cycle. I also have seen and used the "ask permission" popup
which happens when a device not in device_filter.xml is used. I will
test this tomorrow by removing "my" entry from the device_filter.xml.

>
> /D
Best regards
Christof
>
>
>
> _______________________________________________
> subsurface mailing list
> subsurface at subsurface-divelog.org
> http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20200307/6e110081/attachment-0001.html>


More information about the subsurface mailing list