|
@@ -1,7 +1,5 @@
|
|
|
package com.hb.proj.gather.protocol;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
@@ -58,9 +56,6 @@ public class ZLOpdProtHandler extends ChannelInboundHandlerAdapter {
|
|
|
return ;
|
|
|
}
|
|
|
|
|
|
- //byte[] allBytes=new byte[byteBuf.readableBytes()];
|
|
|
- //byteBuf.readBytes(allBytes);
|
|
|
-
|
|
|
|
|
|
//开头两字节且不以0103开头,就认为是心跳数据-作为设备号,该方法并不可靠,有可能把采集的残包数据当作心跳
|
|
|
if(byteCount==2&&(!hexmsg.startsWith("0103"))) {
|
|
@@ -82,19 +77,9 @@ public class ZLOpdProtHandler extends ChannelInboundHandlerAdapter {
|
|
|
}
|
|
|
|
|
|
//读取头部+数据区
|
|
|
- /*
|
|
|
- byte[] headAndDatas=new byte[datalen+headBtyCount];
|
|
|
- byteBuf.readerIndex(0); //重置读索引至起始
|
|
|
- byteBuf.readBytes(headAndDatas);
|
|
|
- */
|
|
|
byte[] headAndDatas=ByteBufUtil.getBytes(byteBuf,0,headBtyCount+datalen);
|
|
|
|
|
|
//读取校验位
|
|
|
- /*
|
|
|
- byte[] crc16=new byte[crc16BtyCount];
|
|
|
- byteBuf.readerIndex(datalen+headBtyCount);
|
|
|
- byteBuf.readBytes(crc16);*/
|
|
|
-
|
|
|
byte[] crc16=ByteBufUtil.getBytes(byteBuf,headBtyCount+datalen,2);
|
|
|
|
|
|
int calCrc16=Crc16Utils.getCRC(headAndDatas);
|
|
@@ -103,7 +88,7 @@ public class ZLOpdProtHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
|
if(ByteUtils.byte2ToIntHL(crc16)==calCrc16) { //crc校验通过
|
|
|
|
|
|
- List<Float> smpdatas=GatherRespParser.parseFloat(byteBuf,headBtyCount,datalen);
|
|
|
+ GatherRespParser.parseShort(byteBuf,headBtyCount,datalen);
|
|
|
|
|
|
}
|
|
|
}
|