You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_COMM) {
if(controlInterfaceCount == mPortNumber) {
mControlIndex = i;
mControlInterface = usbInterface;
}
controlInterfaceCount++;
}
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_CDC_DATA) {
if(dataInterfaceCount == mPortNumber) {
mDataInterface = usbInterface;
}
dataInterfaceCount++;
}
}
The loop itterates over the interfaces and select the "mPortNumber" ACM DATA interface it encouters.
It is not a problem if there are even quantity of ACM CONTROL and DATA interfaces, but it does in other cases.
I use the package to communicate with DJI remote control serial port.
It has Serial module, RNDIS (Remote Network Driver Interface Specification) module and a Mass Storage module.
The UsbDevice of this remote control has the next 6 interfaces:
1.
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_COMM) {
if(controlInterfaceCount == mPortNumber) {
mControlIndex = i;
mControlInterface = usbInterface;
}
controlInterfaceCount++;
}
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_CDC_DATA) {
if(dataInterfaceCount == mPortNumber) {
mDataInterface = usbInterface;
}
dataInterfaceCount++;
}
}
The CdcAcmSerialDriver recognize interface 5 as the only ACM control interface (mControlInterface).
But also recognize two ACM data interfaces (inteface 2 and interface 6).
So it regonize 1 Control Interface and 2 Data interfaces.
It automatically selects the first data interface in the list ,interface 2.
But the interface 2 is the DATA interface of CONTROL interface 1 (RNDIS module) and not of CONTROL interface 5.
THE WORKAROUND
In my work around I build my own CdcAcmSerialDriver that inherit from CdcAcmSerialDriver and rewrote the openInterface().
My assumption that the DATA interface will always be numarted after the CONTROL interface.
So I changed the line:
I only have devices where the control interface comes before the data interface, but I could not find any hint in the USB statndard that they have to be ordered like that.
The USB standard has 'Interface Association Descriptors' (IAD) to group interfaces, but looks like these are filtered out on lower layer and are not accessible to the library.
According to the linux kernel, RNDIS is a variant of CDC ACM, so might be an option to skip data interfaces if rndis control interface USB_INTERFACE_INFO(USB_CLASS_WIRELESS_CONTROLLER, 1, 3) is found
kai-morich
changed the title
Multiple ACM Data Interfaces
composite CDC ACM + RNDIS devices
Feb 10, 2023
Hello. Great package!
SETUP DESCRIPTION
I encountered the next problem in the CdcAcmSerialDriver:
usb-serial-for-android/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/driver/CdcAcmSerialDriver.java
Lines 140 to 155 in 6ffb666
The loop itterates over the interfaces and select the "mPortNumber" ACM DATA interface it encouters.
It is not a problem if there are even quantity of ACM CONTROL and DATA interfaces, but it does in other cases.
I use the package to communicate with DJI remote control serial port.
It has Serial module, RNDIS (Remote Network Driver Interface Specification) module and a Mass Storage module.
The UsbDevice of this remote control has the next 6 interfaces:
1.
THE PROBLEM
So where is the problem?
During the interface scanning in code:
usb-serial-for-android/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/driver/CdcAcmSerialDriver.java
Lines 140 to 155 in 6ffb666
The CdcAcmSerialDriver recognize interface 5 as the only ACM control interface (mControlInterface).
But also recognize two ACM data interfaces (inteface 2 and interface 6).
So it regonize 1 Control Interface and 2 Data interfaces.
It automatically selects the first data interface in the list ,interface 2.
But the interface 2 is the DATA interface of CONTROL interface 1 (RNDIS module) and not of CONTROL interface 5.
THE WORKAROUND
In my work around I build my own CdcAcmSerialDriver that inherit from CdcAcmSerialDriver and rewrote the openInterface().
My assumption that the DATA interface will always be numarted after the CONTROL interface.
So I changed the line:
usb-serial-for-android/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/driver/CdcAcmSerialDriver.java
Line 150 in 6ffb666
to:
or in Kotlin:
The text was updated successfully, but these errors were encountered: