From 6da1eed12ec86d948971408e757160d5d82c61c1 Mon Sep 17 00:00:00 2001 From: Felipe Herranz Date: Sun, 28 Feb 2016 19:44:54 +0100 Subject: [PATCH] style adapted --- .../com/felhr/usbserial/FTDISerialDevice.java | 22 ++++++++++++------- .../com/felhr/usbserial/UsbSerialDevice.java | 3 ++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/usbserial/src/main/java/com/felhr/usbserial/FTDISerialDevice.java b/usbserial/src/main/java/com/felhr/usbserial/FTDISerialDevice.java index 6cf08441..abbd90e7 100644 --- a/usbserial/src/main/java/com/felhr/usbserial/FTDISerialDevice.java +++ b/usbserial/src/main/java/com/felhr/usbserial/FTDISerialDevice.java @@ -572,16 +572,19 @@ 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++; } @@ -589,26 +592,29 @@ public int syncRead(byte[] buffer, int timeout) 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; } diff --git a/usbserial/src/main/java/com/felhr/usbserial/UsbSerialDevice.java b/usbserial/src/main/java/com/felhr/usbserial/UsbSerialDevice.java index f8731e43..bc48f82d 100644 --- a/usbserial/src/main/java/com/felhr/usbserial/UsbSerialDevice.java +++ b/usbserial/src/main/java/com/felhr/usbserial/UsbSerialDevice.java @@ -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; }