UsbSerialForAndroid icon indicating copy to clipboard operation
UsbSerialForAndroid copied to clipboard

CdcAcmSerialDriver resolves wrong interfaces In/Out

Open konradzuse opened this issue 3 years ago • 1 comments

I have a CDC device that wasn't working. After some debugging in the CDC driver code, I realised that the IN and OUT interfaces were mixed up. The code assumes the order is always the same.

I rewrote it to be like this;

int numberEndpoints = mDataInterface.EndpointCount;
                
                for(var i=0;i<=numberEndpoints-1;i++)
                {
                    var endpoint = mDataInterface.GetEndpoint(i);
                    if(endpoint.Type == UsbAddressing.XferBulk
                       && endpoint.Direction == UsbAddressing.In)
                    {
                        mReadEndpoint = endpoint;
                    }else if(endpoint.Type == UsbAddressing.XferBulk
                             && endpoint.Direction == UsbAddressing.Out)
                    {
                        mWriteEndpoint = endpoint;
                    }
                }

so the ordering of the interfaces no longer matters, it should resolve the In and Out interfaces according to their direction.

Hope this helps someone else stuck with this.

konradzuse avatar Jul 04 '22 23:07 konradzuse

If you would like to submit a pull request, we would be happy to review it.

anotherlab avatar May 08 '23 15:05 anotherlab