wuzeyu
2024-11-27 e2c28bc98587c6edd6a38f06b972ff51d998028f
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/CommonV1.java
@@ -1,12 +1,16 @@
package com.dy.common.mw.protocol.p206V1;
import com.dy.common.mw.channel.tcp.TcpIoSessionAttrIdIsRtuAddr;
import com.dy.common.util.ByteUtil;
import com.dy.common.util.ByteUtilUnsigned;
import com.dy.common.util.CRC16;
import com.dy.common.util.CRC8_for_2_0;
import org.apache.mina.core.session.IoSession;
public class CommonV1 {
   /**
    * 检查头
    * @param bs 上行字节数组
@@ -75,7 +79,7 @@
         int len = ByteUtilUnsigned.byte2Byte(bs, ProtocolConstantV206V1.dataLenIndex);
         return len + ProtocolConstantV206V1.lenHead2ctrl + ProtocolConstantV206V1.lenTail;
      }else{
         int len = ByteUtilUnsigned.bytes2Short_BE(bs, ProtocolConstantV206V1.UG_dataLenIndex_start);
         int len = ByteUtilUnsigned.bytes2Short_LE(bs, ProtocolConstantV206V1.UG_dataLenIndex_start);
         return len + ProtocolConstantV206V1.UG_lenHead2Cmd + ProtocolConstantV206V1.UG_lenTail;
      }
   }
@@ -176,8 +180,9 @@
            return "计算CRC是:" + crcCompute + ",上传CRC是" + crcInBs ;
         }
      }else{
         int crcCompute = (byte)new CRC16().CRC(bs, ProtocolConstantV206V1.ctrlIndex, bs.length - 3) ;
         int crcInBs = ByteUtilUnsigned.bytes2Short_BE(bs, bs.length - 3) ;
         short crcCompute = new CRC16().CRC(bs, 0, bs.length - 4) ;
         short crcInBs = ByteUtil.bytes2Short_BE(bs,bs.length - 3) ;
         //int crcInBs = ByteUtilUnsigned.bytes2Short_BE(bs, bs.length - 3) ;
         if(crcCompute == crcInBs){
            return null ;
         }else{