Skip to content

Commit 863494b

Browse files
Alex van HerwijnenAlex van Herwijnen
authored andcommitted
Fixing GetSupportedDevices
1 parent 7617f5e commit 863494b

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

UsbSerialForAndroid/driver/ProlificSerialDriver.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Hoho.Android.UsbSerial.Driver
2323
{
2424
public class ProlificSerialDriver : UsbSerialDriver
2525
{
26-
private readonly string TAG = typeof (ProlificSerialDriver).Name;
26+
private readonly string TAG = typeof(ProlificSerialDriver).Name;
2727

2828
public ProlificSerialDriver(UsbDevice device)
2929
{
@@ -38,7 +38,14 @@ public static Dictionary<int, int[]> GetSupportedDevices()
3838
{
3939
UsbId.VENDOR_PROLIFIC, new int[]
4040
{
41-
UsbId.VENDOR_PROLIFIC
41+
UsbId.PROLIFIC_PL2303,
42+
UsbId.PROLIFIC_PL2303GC,
43+
UsbId.PROLIFIC_PL2303GB,
44+
UsbId.PROLIFIC_PL2303GT,
45+
UsbId.PROLIFIC_PL2303GL,
46+
UsbId.PROLIFIC_PL2303GE,
47+
UsbId.PROLIFIC_PL2303GS
48+
4249
}
4350
}
4451
};
@@ -126,7 +133,7 @@ private byte[] InControlTransfer(int requestType, int request,
126133
int value, int index, int length)
127134
{
128135
byte[] buffer = new byte[length];
129-
int result = mConnection.ControlTransfer((UsbAddressing) requestType, request, value,
136+
int result = mConnection.ControlTransfer((UsbAddressing)requestType, request, value,
130137
index, buffer, length, USB_READ_TIMEOUT_MILLIS);
131138
if (result != length)
132139
{
@@ -139,7 +146,7 @@ private void OutControlTransfer(int requestType, int request,
139146
int value, int index, byte[] data)
140147
{
141148
int length = data?.Length ?? 0;
142-
int result = mConnection.ControlTransfer((UsbAddressing) requestType, request, value,
149+
int result = mConnection.ControlTransfer((UsbAddressing)requestType, request, value,
143150
index, data, length, USB_WRITE_TIMEOUT_MILLIS);
144151
if (result != length)
145152
{
@@ -303,21 +310,21 @@ public override void Open(UsbDeviceConnection connection)
303310

304311
switch (currentEndpoint.Address)
305312
{
306-
case (UsbAddressing) READ_ENDPOINT:
313+
case (UsbAddressing)READ_ENDPOINT:
307314
mReadEndpoint = currentEndpoint;
308315
break;
309316

310-
case (UsbAddressing) WRITE_ENDPOINT:
317+
case (UsbAddressing)WRITE_ENDPOINT:
311318
mWriteEndpoint = currentEndpoint;
312319
break;
313320

314-
case (UsbAddressing) INTERRUPT_ENDPOINT:
321+
case (UsbAddressing)INTERRUPT_ENDPOINT:
315322
mInterruptEndpoint = currentEndpoint;
316323
break;
317324
}
318325
}
319326

320-
if (mDevice.DeviceClass == (UsbClass) 0x02)
327+
if (mDevice.DeviceClass == (UsbClass)0x02)
321328
{
322329
mDeviceType = DEVICE_TYPE_0;
323330
}
@@ -338,7 +345,7 @@ public override void Open(UsbDeviceConnection connection)
338345
mDeviceType = DEVICE_TYPE_HX;
339346
}
340347
else if ((mDevice.DeviceClass == 0x00)
341-
|| (mDevice.DeviceClass == (UsbClass) 0xff))
348+
|| (mDevice.DeviceClass == (UsbClass)0xff))
342349
{
343350
mDeviceType = DEVICE_TYPE_1;
344351
}
@@ -484,10 +491,10 @@ public override void SetParameters(int baudRate, int dataBits, StopBits stopBits
484491

485492
byte[] lineRequestData = new byte[7];
486493

487-
lineRequestData[0] = (byte) (baudRate & 0xff);
488-
lineRequestData[1] = (byte) ((baudRate >> 8) & 0xff);
489-
lineRequestData[2] = (byte) ((baudRate >> 16) & 0xff);
490-
lineRequestData[3] = (byte) ((baudRate >> 24) & 0xff);
494+
lineRequestData[0] = (byte)(baudRate & 0xff);
495+
lineRequestData[1] = (byte)((baudRate >> 8) & 0xff);
496+
lineRequestData[2] = (byte)((baudRate >> 16) & 0xff);
497+
lineRequestData[3] = (byte)((baudRate >> 24) & 0xff);
491498

492499
switch (stopBits)
493500
{
@@ -533,7 +540,7 @@ public override void SetParameters(int baudRate, int dataBits, StopBits stopBits
533540
throw new IllegalArgumentException("Unknown parity value: " + parity);
534541
}
535542

536-
lineRequestData[6] = (byte) dataBits;
543+
lineRequestData[6] = (byte)dataBits;
537544

538545
CtrlOut(SET_LINE_REQUEST, 0, 0, lineRequestData);
539546

0 commit comments

Comments
 (0)