Skip to content

Commit 1b1b565

Browse files
committed
both v3 and v4 and the switch over now working for the serial interface
1 parent a3ede9e commit 1b1b565

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

javasdk/NRSDK/src/com/neuronrobotics/sdk/common/BowlerAbstractConnection.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,30 +1180,31 @@ public void setBeater(boolean beater) {
11801180
}
11811181

11821182
public BowlerDatagram loadPacketFromPhy(ByteList bytesToPacketBuffer) throws NullPointerException, IOException{
1183-
BowlerDatagram bd=null;
1183+
BowlerDatagram bd=BowlerDatagramFactory.build(bytesToPacketBuffer);
11841184
if(dataIns!=null){
1185-
byte [] buff = new byte[getDataIns().available()];
1186-
if(buff.length==0)
1185+
int have = getDataIns().available();
1186+
if(have==0)
11871187
return null;
11881188
int b,ret =0;
11891189

11901190
try{
1191-
for(b=0;b<buff.length;b++){
1191+
for(b=0;b<have;b++){
1192+
if(bd!=null)
1193+
Log.error("Adding "+(have-b-1)+" after packet found");
11921194
ret = getDataIns().read();
11931195
if(ret<0){
11941196
Log.error("Stream is broken - unexpected: claimed to have "+getDataIns().available()+" bytes, read in "+b);
11951197
//reconnect();
11961198
//something went wrong
1197-
new RuntimeException(" Buffer attempted to read "+buff.length+" got "+b).printStackTrace();
1199+
new RuntimeException(" Buffer attempted to read "+have+" got "+b).printStackTrace();
11981200
return null;
11991201
}else{
12001202
bytesToPacketBuffer.add(ret);
12011203
if(bd==null)
1202-
try{
1203-
bd = BowlerDatagramFactory.build(bytesToPacketBuffer);
1204-
}catch(Exception ex){
1205-
ex.printStackTrace();
1206-
}
1204+
bd = BowlerDatagramFactory.build(bytesToPacketBuffer);
1205+
if(bd!=null)
1206+
return bd;
1207+
12071208
}
12081209

12091210
}

0 commit comments

Comments
 (0)