kopia lustrzana https://github.com/felHR85/UsbSerial
Synchronous write now works with FTDI devices
rodzic
8ed36b0c73
commit
ce1dc92f4e
|
@ -149,15 +149,23 @@ public abstract class UsbSerialDevice implements UsbSerialInterface
|
||||||
return connection.bulkTransfer(inEndpoint, buffer, buffer.length, timeout);
|
return connection.bulkTransfer(inEndpoint, buffer, buffer.length, timeout);
|
||||||
}else // FTDI devices need special treatment
|
}else // FTDI devices need special treatment
|
||||||
{
|
{
|
||||||
int numberBytes = connection.bulkTransfer(inEndpoint, buffer, buffer.length, timeout);
|
int n = buffer.length / 62;
|
||||||
|
if(buffer.length % 62 != 0)
|
||||||
|
n++;
|
||||||
|
|
||||||
|
byte[] tempBuffer = new byte[buffer.length + n * 2];
|
||||||
|
int numberBytes = connection.bulkTransfer(inEndpoint, tempBuffer, tempBuffer.length, timeout);
|
||||||
|
|
||||||
if(numberBytes > 2) // Data received
|
if(numberBytes > 2) // Data received
|
||||||
{
|
{
|
||||||
buffer = ((FTDISerialDevice) this).ftdiUtilities.adaptArray(buffer);
|
byte[] newBuffer = ((FTDISerialDevice) this).ftdiUtilities.adaptArray(tempBuffer);
|
||||||
return numberBytes - 2;
|
System.arraycopy(newBuffer, 0, buffer, 0, buffer.length);
|
||||||
}else if(numberBytes == 2) // Modem status
|
|
||||||
{
|
int p = numberBytes / 64;
|
||||||
return 0;
|
if(numberBytes % 64 != 0)
|
||||||
}else // No data received
|
p++;
|
||||||
|
return numberBytes - p * 2;
|
||||||
|
}else
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue