| | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | |
| | | GlCreate.createLen4PUg(preBytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(preBytes, bsTail) ; |
| | |
| | | ByteUtil.hex2Bytes(vo.softStartAddr, bs, 0) ; |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | GlCreate.createLen4PUg(bytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(bytes, bsTail) ; |
| | |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, (byte[])para.attachment) ; |
| | | |
| | | GlCreate.createLen4PUg(bytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(bytes, bsTail) ; |
| | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | |
| | | GlCreate.createLen4PUg(preBytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(preBytes, bsTail) ; |
| | |
| | | package com.dy.common.mw.protocol.p206V2.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | import com.dy.common.mw.protocol.p206V2.CodeV2; |
| | | import com.dy.common.mw.protocol.p206V2.ParseParamsForDownV2; |
| | | import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2; |
| | | import com.dy.common.mw.protocol.p206V2.parse.global.GlCreate; |
| | | import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate; |
| | | import com.dy.common.util.ByteUtil; |
| | | |
| | | /** |
| | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | |
| | | GlCreate.createLen4PUg(preBytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(preBytes, bsTail) ; |
| | |
| | | import com.dy.common.mw.protocol.p206V2.CodeV2; |
| | | import com.dy.common.mw.protocol.p206V2.ParseParamsForDownV2; |
| | | import com.dy.common.mw.protocol.p206V2.ProtocolConstantV206V2; |
| | | import com.dy.common.mw.protocol.p206V2.parse.global.GlCreate; |
| | | import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate; |
| | | import com.dy.common.softUpgrade.Com1601Vo; |
| | | import com.dy.common.util.ByteUtil; |
| | | |
| | |
| | | ByteUtil.hex2Bytes(vo.softStartAddr, bs, 0) ; |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | GlCreate.createLen4PUg(bytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(bytes, bsTail) ; |
| | |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, (byte[])para.attachment) ; |
| | | |
| | | GlCreate.createLen4PUg(bytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(bytes, bsTail) ; |
| | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | |
| | | GlCreate.createLen4PUg(preBytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(preBytes, bsTail) ; |
| | |
| | | bsNoTail[ProtocolConstantV206V2.dataLenIndex] = (byte)len ; |
| | | } |
| | | |
| | | public static void createLen4PUg(byte[] bytes) throws Exception { |
| | | int len = bytes.length - 4; |
| | | byte[] bs = ByteUtil.int2BCD_LE(len) ; |
| | | if(bs != null && bs.length == 1){ |
| | | bytes[1] = bs[0] ; |
| | | }else if(bs != null && bs.length > 1){ |
| | | bytes[1] = bs[0] ; |
| | | bytes[2] = bs[1] ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 生成IC卡编码 |
| | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | |
| | | GlCreate.createLen4PUg(preBytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(preBytes, bsTail) ; |
| | |
| | | ByteUtil.hex2Bytes(vo.softStartAddr, bs, 0) ; |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | GlCreate.createLen4PUg(bytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(bytes, bsTail) ; |
| | |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, (byte[])para.attachment) ; |
| | | |
| | | GlCreate.createLen4PUg(bytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(bytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(bytes, bsTail) ; |
| | |
| | | index += 2 ; |
| | | GlCreate.createRtuAddr4PUg(para.rtuAddr, preBytes, index); |
| | | |
| | | GlCreate.createLen4PUg(preBytes);//长度放字节数组中 |
| | | |
| | | byte[] bsTail = GlCreate.createCrcTail4Ug(preBytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | return ByteUtil.bytesMerge(preBytes, bsTail) ; |
| | |
| | | bsNoTail[ProtocolConstantV206V1.dataLenIndex] = (byte)len ; |
| | | } |
| | | |
| | | public static void createLen4PUg(byte[] bytes) throws Exception { |
| | | int len = bytes.length - 4; |
| | | byte[] bs = ByteUtil.int2BCD_LE(len) ; |
| | | if(bs != null && bs.length == 1){ |
| | | bytes[1] = bs[0] ; |
| | | }else if(bs != null && bs.length > 1){ |
| | | bytes[1] = bs[0] ; |
| | | bytes[2] = bs[1] ; |
| | | } |
| | | } |
| | | |
| | | public static byte[] createCrcTail(byte[] bsNoTail) throws Exception { |
| | | int crc = new CRC8_for_2_0().CRC8(bsNoTail, ProtocolConstantV206V1.ctrlIndex, bsNoTail.length -1) ; |
| | | byte[] bytes = new byte[ProtocolConstantV206V1.lenTail] ; |