pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/parse/global/GlCreate.java
@@ -54,7 +54,7 @@ public static void createLen4PUg(byte[] bytes) throws Exception { int len = bytes.length - 4; byte[] bs = ByteUtil.int2BCD_LE(len) ; byte[] bs = ByteUtil.short2Bytes_LE((short)len) ; if(bs != null && bs.length == 1){ bytes[1] = 0 ; bytes[2] = bs[0] ; pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V2/parse/global/GlCreate.java
@@ -56,7 +56,7 @@ public static void createLen4PUg(byte[] bytes) throws Exception { int len = bytes.length - 4; byte[] bs = ByteUtil.int2BCD_LE(len) ; byte[] bs = ByteUtil.short2Bytes_LE((short)len) ; if(bs != null && bs.length == 1){ bytes[1] = 0 ; bytes[2] = bs[0] ; pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/global/GlCreate.java
@@ -148,7 +148,7 @@ public static void createLen4PUg(byte[] bytes) throws Exception { int len = bytes.length - 4; byte[] bs = ByteUtil.int2BCD_LE(len) ; byte[] bs = ByteUtil.short2Bytes_LE((short)len) ; if(bs != null && bs.length == 1){ bytes[1] = 0 ; bytes[2] = bs[0] ; pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/CRC16.java
@@ -1,6 +1,8 @@ package com.dy.common.util; import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; @SuppressWarnings("unused") public final class CRC16 { @@ -138,6 +140,33 @@ System.arraycopy(new byte[] {(byte)(c - ((c / 256) * 256)) }, 0, crc, 1, 1); return crc; } public static void main(String[] args) throws Exception { //String hex = "AA0024AA // 16015301 // 15059980 // 00011000 // 00014A00 // 5D4D5D4D // 00004000 // AAC616" ; String hex = "AA0024AA16015301150599800001100000014A005D4D5D4D00004000" ; byte[] bs = ByteUtil.hex2Bytes(hex) ; // for(int i = 0 ; i < bs.length - 2 ; i++){ // short crc = new CRC16().CRC16_table(bs, i , bs.length - 1) ; // byte[] bytes = new byte[ProtocolConstantV206V1.UG_lenTail] ; // ByteUtil.short2Bytes_LE(bytes, crc, 0); // bytes[2] = ProtocolConstantV206V1.P_Tail_Byte ; // System.out.println(ByteUtil.bytes2Hex(bytes, true)) ; // } System.out.println("==============================") ; for(int i = 4 ; i < bs.length ; i++){ short crc = new CRC16().CRC16_table(bs, 0 , i) ; byte[] bytes = new byte[ProtocolConstantV206V1.UG_lenTail] ; ByteUtil.short2Bytes_LE(bytes, crc, 0); bytes[2] = ProtocolConstantV206V1.P_Tail_Byte ; System.out.println(ByteUtil.bytes2Hex(bytes, true)) ; } } }