Closed elicec closed 1 year ago
SET_CONTROL_LINE_STATE = 0x22;
is also used in CdcAcm driver and interface / endpoint handling looks basically the same as openSingleInterface
there. Have you tried using the CdcAdm driver?
The Linux kernel includes various excotic or very old drivers. For which devices will this driver be used? I could not find your VID/PID.
private void openSingleInterface() throws IOException {
// the following code is inspired by the cdc-acm driver in the linux kernel
mControlIndex = 0;
mControlInterface = mDevice.getInterface(0);
mDataInterface = mDevice.getInterface(0);
if (!mConnection.claimInterface(mControlInterface, true)) {
throw new IOException("Could not claim shared control/data interface");
}
for (int i = 0; i < mControlInterface.getEndpointCount(); ++i) {
UsbEndpoint ep = mControlInterface.getEndpoint(i);
if ((ep.getDirection() == UsbConstants.USB_DIR_IN) && (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT)) {
mControlEndpoint = ep;
} else if ((ep.getDirection() == UsbConstants.USB_DIR_IN) && (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK)) {
mReadEndpoint = ep;
} else if ((ep.getDirection() == UsbConstants.USB_DIR_OUT) && (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK)) {
mWriteEndpoint = ep;
}
}
if (mControlEndpoint == null) {
throw new IOException("No control endpoint");
}
}
I try your suggestion, but the device has no ControlEndpoint
the mControlEndpoint
is only used to determine mControlIndex
which anyway is zero here for the default control endpoint. Does the CdcAcm driver work without this check?
if (mControlEndpoint == null) {
throw new IOException("No control endpoint");
}
Please provide mDevice.getInterface(0).toString()
mDevice.getInterface(0).toString()
UsbInterface[mId=0,mAlternateSetting=0,mName=Unisoc Generic Serial,mClass=255,mSubclass=0,mProtocol=0,mEndpoints=[
UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=512,mInterval=0]
UsbEndpoint[mAddress=1,mAttributes=2,mMaxPacketSize=512,mInterval=0]]
It also cant work without the check. It throw IOException("controlTransfer failed");
private int sendAcmControlMessage(int request, int value, byte[] buf) throws IOException {
int len = mConnection.controlTransfer(
USB_RT_ACM, request, value, mControlIndex, buf, buf != null ? buf.length : 0, 5000);
if(len < 0) {
throw new IOException("controlTransfer failed");
}
return len;
}
I see. Your driver also does mConnection.controlTransfer but uses 0 instead of USB_RT_ACM.
The Linux driver is ~10 years old. For which devices will it be used? If added to the library, others will also ask "when should I use it?"
Referenc linux kernel code drivers/usb/serial/usb_wwan.c drivers/usb/serial/option.c