anotherlab / UsbSerialForAndroid

A Xamarin C# port of the Java usb-serial-for-android library
MIT License
158 stars 70 forks source link

IOException for Prolific PL2303GT (prodId 9155 / 0x23c3) #57

Open elynden opened 6 months ago

elynden commented 6 months ago

Device in title is not recognized as the correct device type of HXN, but rather type T. This results in an IOException. It's because it does not do the TestHxStatus() check if deviceVersion == 0x300 & usbVersion ==0x200. The original Java code does do this check.

Method is Open(UsbDeviceConnection connection). Currently lines 373 to 392.

The following code in ProlificSerialDriver.cs needs to be replaced: if (mDevice.DeviceClass == UsbClass.Comm || maxPacketSize0 != 64) { mDeviceType = DeviceType.DEVICE_TYPE_01; } else if (deviceVersion == 0x300 && usbVersion == 0x200) { mDeviceType = DeviceType.DEVICE_TYPE_T; // TA } else if (deviceVersion == 0x500) { mDeviceType = DeviceType.DEVICE_TYPE_T; // TB } else if (usbVersion == 0x200 && !TestHxStatus()) { mDeviceType = DeviceType.DEVICE_TYPE_HXN; } else { mDeviceType = DeviceType.DEVICE_TYPE_HX; }

Replace with: if (mDevice.DeviceClass == UsbClass.Comm || maxPacketSize0 != 64) { mDeviceType = DeviceType.DEVICE_TYPE_01; } else if (usbVersion == 0x200) { if ((deviceVersion == 0x300 || deviceVersion == 0x500) && TestHxStatus()) { mDeviceType = DeviceType.DEVICE_TYPE_T; // TA & TB } else { mDeviceType = DeviceType.DEVICE_TYPE_HXN; } } else { mDeviceType = DeviceType.DEVICE_TYPE_HX; }

anotherlab commented 6 months ago

If your suggested change works with your hardware, please submit a pull request for that change.