Skip to content

Commit

Permalink
style adapted
Browse files Browse the repository at this point in the history
  • Loading branch information
felHR85 committed Feb 28, 2016
1 parent c67ba4b commit 6da1eed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
22 changes: 14 additions & 8 deletions usbserial/src/main/java/com/felhr/usbserial/FTDISerialDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,43 +572,49 @@ public int syncRead(byte[] buffer, int timeout)
long beginTime = System.currentTimeMillis();
long stopTime = beginTime + timeout;

if (asyncMode) {
if(asyncMode)
{
return -1;
}

if (buffer == null) {
if(buffer == null)
{
return 0;
}

int n = buffer.length / 62;
if (buffer.length % 62 != 0) {
if(buffer.length % 62 != 0)
{
n++;
}

byte[] tempBuffer = new byte[buffer.length + n * 2];

int readen = 0;

do {
do
{
int timeLeft = (int) (stopTime - System.currentTimeMillis());
if (timeLeft <= 0) {
if(timeLeft <= 0)
{
break;
}

int numberBytes = connection.bulkTransfer(inEndpoint, tempBuffer, tempBuffer.length, timeLeft);

if (numberBytes > 2) // Data received
if(numberBytes > 2) // Data received
{
byte[] newBuffer = this.ftdiUtilities.adaptArray(tempBuffer);
System.arraycopy(newBuffer, 0, buffer, 0, buffer.length);

int p = numberBytes / 64;
if (numberBytes % 64 != 0) {
if(numberBytes % 64 != 0)
{
p++;
}
readen = numberBytes - p * 2;
}
} while (readen <= 0);
}while(readen <= 0);

return readen;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ public int syncWrite(byte[] buffer, int timeout)
@Override
public int syncRead(byte[] buffer, int timeout)
{
if (asyncMode) {
if(asyncMode)
{
return -1;
}

Expand Down

0 comments on commit 6da1eed

Please sign in to comment.