From 102c992e50d72b5120c858f7794c137c92d78b9d Mon Sep 17 00:00:00 2001 From: Colby Skeggs Date: Sun, 18 Jan 2015 01:30:19 +0000 Subject: [PATCH] Fixes artf3989: Java SerialPort no longer ignores return value of serialRead Change-Id: I5d522111189372a3c95b90804abf05ae1d0b553e --- .../src/main/java/edu/wpi/first/wpilibj/SerialPort.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SerialPort.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SerialPort.java index 8ed129d3ac..56d164fd9a 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SerialPort.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SerialPort.java @@ -362,9 +362,9 @@ public class SerialPort { ByteBuffer status = ByteBuffer.allocateDirect(4); status.order(ByteOrder.LITTLE_ENDIAN); ByteBuffer dataReceivedBuffer = ByteBuffer.allocateDirect(count); - SerialPortJNI.serialRead(m_port, dataReceivedBuffer, count, status.asIntBuffer()); + int gotten = SerialPortJNI.serialRead(m_port, dataReceivedBuffer, count, status.asIntBuffer()); HALUtil.checkStatus(status.asIntBuffer()); - byte[] retVal = new byte[count]; + byte[] retVal = new byte[gotten]; dataReceivedBuffer.get(retVal); return retVal; }