diff --git a/ch.psi.fda.fdaq/pom.xml b/ch.psi.fda.fdaq/pom.xml index 803439e..92a5242 100644 --- a/ch.psi.fda.fdaq/pom.xml +++ b/ch.psi.fda.fdaq/pom.xml @@ -3,7 +3,7 @@ 4.0.0 ch.psi ch.psi.fda.fdaq - 1.0.9 + 1.0.13 diff --git a/ch.psi.fda.fdaq/src/main/java/ch/psi/fda/fdaq/Fdaq.java b/ch.psi.fda.fdaq/src/main/java/ch/psi/fda/fdaq/Fdaq.java index 202f42b..56286a1 100644 --- a/ch.psi.fda.fdaq/src/main/java/ch/psi/fda/fdaq/Fdaq.java +++ b/ch.psi.fda.fdaq/src/main/java/ch/psi/fda/fdaq/Fdaq.java @@ -20,6 +20,7 @@ package ch.psi.fda.fdaq; import java.io.DataInputStream; import java.io.DataOutputStream; +import java.io.EOFException; import java.io.IOException; import java.net.Socket; import java.nio.ByteBuffer; @@ -109,11 +110,13 @@ public class Fdaq { for (int t = 0; t < numberOfElements; t++) { // struct fdaqbloc_out {int trigindex;int adc1reg;int // adc2reg;int encoder;}; - ByteBuffer buffer = ByteBuffer.allocate(4 * 4); // 4 times - // Integers - buffer.order(ByteOrder.LITTLE_ENDIAN); - int r = in.read(buffer.array()); - if (r == -1) { + + byte[] cbuffer = new byte[4*4]; // 4 times Integers a 4 bytes + + try{ + in.readFully(cbuffer); + } + catch(EOFException e){ logger.info("End of Stream"); break; } @@ -125,6 +128,8 @@ public class Fdaq { continue; } + ByteBuffer buffer = ByteBuffer.wrap(cbuffer); + buffer.order(ByteOrder.LITTLE_ENDIAN); int a = buffer.getInt(); int b = buffer.getInt(); int b1 = b & 0xffff;