|
@@ -1,5 +1,6 @@
|
|
|
package at.acdp.urweb.sclient;
|
|
|
|
|
|
+import at.acdp.urweb.CountDataInputStream;
|
|
|
import at.acdp.urweb.sclient.data.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -17,7 +18,7 @@ public class SecondaryClient {
|
|
|
private volatile boolean _running = true;
|
|
|
private Socket rt;
|
|
|
private OutputStream os;
|
|
|
- private DataInputStream in;
|
|
|
+ private CountDataInputStream in;
|
|
|
|
|
|
public SecondaryClient(String ip, int port) {
|
|
|
this.ip = ip;
|
|
@@ -27,14 +28,14 @@ public class SecondaryClient {
|
|
|
public VersionMessage connect() throws IOException {
|
|
|
this.rt = new Socket(ip, port);
|
|
|
this.os = rt.getOutputStream();
|
|
|
- this.in = new DataInputStream(rt.getInputStream());
|
|
|
+ this.in = new CountDataInputStream(rt.getInputStream());
|
|
|
VersionMessage vm = new VersionMessage();
|
|
|
vm.read(in, -1);
|
|
|
return vm;
|
|
|
}
|
|
|
|
|
|
- public void readReply(DataInputStream di) throws IOException {
|
|
|
-
|
|
|
+ public void readReply(CountDataInputStream di) throws IOException {
|
|
|
+ int beforeCount=di.getCount();
|
|
|
int size = di.readInt(); //4
|
|
|
int pType = di.readByte() & 0xff; //+1=5
|
|
|
log.info("ptype: "+pType);
|
|
@@ -82,41 +83,46 @@ public class SecondaryClient {
|
|
|
byte[] pack=new byte[size-5];
|
|
|
di.readFully(pack);
|
|
|
}
|
|
|
+ int afterCount=di.getCount();
|
|
|
+ int diff=afterCount-beforeCount-size;
|
|
|
+ if(diff!=0) {
|
|
|
+ log.warn("size mismatch: " +diff + "package type: "+pType);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private ToolCommInfo readToolCommInfo(DataInputStream di, int size) throws IOException {
|
|
|
+ private ToolCommInfo readToolCommInfo(CountDataInputStream di, int size) throws IOException {
|
|
|
ToolCommInfo tci=new ToolCommInfo();
|
|
|
tci.read(di, size);
|
|
|
return tci;
|
|
|
}
|
|
|
|
|
|
- private void skip(int pType, DataInputStream di, int size) throws IOException {
|
|
|
+ private void skip(int pType, CountDataInputStream di, int size) throws IOException {
|
|
|
log.trace("skip data for package type: "+pType);
|
|
|
byte[] data=new byte[size-5];
|
|
|
di.readFully(data);
|
|
|
}
|
|
|
|
|
|
|
|
|
- private AdditionalInfo readAdditionalInfo(DataInputStream di, int size) throws IOException {
|
|
|
+ private AdditionalInfo readAdditionalInfo(CountDataInputStream di, int size) throws IOException {
|
|
|
AdditionalInfo ai=new AdditionalInfo();
|
|
|
ai.read(di, size);
|
|
|
return ai;
|
|
|
|
|
|
}
|
|
|
|
|
|
- private ForceModeData readForceModeData(DataInputStream di, int size) throws IOException {
|
|
|
+ private ForceModeData readForceModeData(CountDataInputStream di, int size) throws IOException {
|
|
|
ForceModeData fmd=new ForceModeData();
|
|
|
fmd.read(di, size);
|
|
|
return fmd;
|
|
|
}
|
|
|
|
|
|
- private ConfigurationData readConfigurationData(DataInputStream di, int size) throws IOException {
|
|
|
+ private ConfigurationData readConfigurationData(CountDataInputStream di, int size) throws IOException {
|
|
|
ConfigurationData cd=new ConfigurationData();
|
|
|
cd.read(di, size);
|
|
|
return cd;
|
|
|
}
|
|
|
|
|
|
- void readRobotMessage(DataInputStream di, int size) throws IOException {
|
|
|
+ void readRobotMessage(CountDataInputStream di, int size) throws IOException {
|
|
|
long ts = di.readLong();
|
|
|
char source = (char) (di.readByte() & 0xFF);
|
|
|
char robotMessageType = (char) (di.readByte() & 0xFF);
|
|
@@ -130,7 +136,7 @@ public class SecondaryClient {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- void readRobotState(DataInputStream di, int size) throws IOException {
|
|
|
+ void readRobotState(CountDataInputStream di, int size) throws IOException {
|
|
|
long ts = di.readLong();
|
|
|
char source = (char) (di.readByte() & 0xFF);
|
|
|
char robotMessageType = (char) (di.readByte() & 0xFF);
|
|
@@ -142,19 +148,19 @@ public class SecondaryClient {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- CartesianInfo readCartesianInfo(DataInputStream di, int size) throws IOException {
|
|
|
+ CartesianInfo readCartesianInfo(CountDataInputStream di, int size) throws IOException {
|
|
|
CartesianInfo ci = new CartesianInfo();
|
|
|
ci.read(di, size);
|
|
|
return ci;
|
|
|
}
|
|
|
|
|
|
- KinematicsInfo readKinemsticsInfo(DataInputStream di, int size) throws IOException {
|
|
|
+ KinematicsInfo readKinemsticsInfo(CountDataInputStream di, int size) throws IOException {
|
|
|
KinematicsInfo ki = new KinematicsInfo();
|
|
|
ki.read(di, size);
|
|
|
return ki;
|
|
|
}
|
|
|
|
|
|
- ModeData readRobotModeData(DataInputStream di, int size) throws IOException {
|
|
|
+ ModeData readRobotModeData(CountDataInputStream di, int size) throws IOException {
|
|
|
long ts = di.readLong();
|
|
|
ModeData md = new ModeData();
|
|
|
md.realRobotConnected = di.readBoolean();
|
|
@@ -175,7 +181,7 @@ public class SecondaryClient {
|
|
|
return md;
|
|
|
}
|
|
|
|
|
|
- JointData[] readJointData(DataInputStream di, int size) throws IOException {
|
|
|
+ JointData[] readJointData(CountDataInputStream di, int size) throws IOException {
|
|
|
int joints = size / 41;
|
|
|
// byte[] buf=new byte[300];
|
|
|
// di.readFully(buf);
|