From 6cf345bc8fe98d393320b89182f9293171aa19ff Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期二, 22 四月 2025 16:39:55 +0800 Subject: [PATCH] 1、根据江海协议中开阀类型变化,修改相应代码; 2、江海协议RTU模拟器启动参数注释。 --- pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/CommonV1.java | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/CommonV1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/CommonV1.java index d77f480..e4619c3 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/CommonV1.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/CommonV1.java @@ -1,16 +1,20 @@ 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 涓婅瀛楄妭鏁扮粍 - * @return [rt1->true:鏄湰鍗忚P206锛宖alse:涓嶆槸鏈崗璁�; rt2->true:鏄按璧勬簮鍗忚锛宖alse:鏄崌绾у崗璁甝 + * @return [銆�0銆�->true:鏄湰鍗忚P206锛宖alse:涓嶆槸鏈崗璁�; 銆�1銆�->true:鏄按璧勬簮鍗忚锛宖alse:鏄崌绾у崗璁甝 * @throws Exception 寮傚父 */ public Boolean[] isThisProtocolHead(byte[] bs) throws Exception{ @@ -176,8 +180,9 @@ return "璁$畻CRC鏄�:" + crcCompute + "锛屼笂浼燙RC鏄�" + 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{ -- Gitblit v1.8.0