Skip to content

Commit 133ea47

Browse files
authored
Merge branch 'anotherlab:main' into main
2 parents 9530aa6 + 4d73ca7 commit 133ea47

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

UsbSerialForAndroid/driver/CdcAcmSerialDriver.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ public CdcAcmSerialDriver(UsbDevice device, bool? enableAsyncReads = null)
3737
mPort = new CdcAcmSerialPort(device, 0, this, enableAsyncReads);
3838
}
3939

40+
// Additional constructor for ProbeDevice called by Reflection
41+
// Note that this defaults to enableAsyncReads = false as
42+
// there is no support for passing additional arguments from ProbeDevice
43+
public CdcAcmSerialDriver(UsbDevice device)
44+
{
45+
mDevice = device;
46+
bool enableAsyncReads = false; // For clarity of understanding
47+
mPort = new CdcAcmSerialPort(device, 0, this, enableAsyncReads);
48+
}
49+
4050
class CdcAcmSerialPort : CommonUsbSerialPort
4151
{
4252
private bool mEnableAsyncReads;

UsbSerialForAndroid/driver/FtdiSerialDriver.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public FtdiSerialDriver(UsbDevice device)
5959

6060
for (int port = 0; port < device.InterfaceCount; port++)
6161
{
62-
mPorts.Add(new FtdiSerialPort(mDevice, port));
62+
mPorts.Add(new FtdiSerialPort(mDevice, port, this));
6363
}
6464
}
6565

@@ -212,7 +212,7 @@ protected int ReadFilter(byte[] buffer, int totalBytesRead, int maxPacketSize)
212212
if (length < 0)
213213
throw new IOException("Expected at least " + READ_HEADER_LENGTH + " bytes");
214214

215-
Buffer.BlockCopy(buffer, srcPos + READ_HEADER_LENGTH, buffer, destPos, length);
215+
Buffer.BlockCopy(mReadBuffer, srcPos + READ_HEADER_LENGTH, buffer, destPos, length);
216216
destPos += length;
217217
}
218218
return destPos;
@@ -497,4 +497,4 @@ public static Dictionary<int, int[]> GetSupportedDevices()
497497
};
498498
}
499499
}
500-
}
500+
}

0 commit comments

Comments
 (0)