| | |
| | | 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,false:不是本协议; rt2->true:是水资源协议,false:是升级协议] |
| | | * @return [【0】->true:是本协议P206,false:不是本协议; 【1】->true:是水资源协议,false:是升级协议] |
| | | * @throws Exception 异常 |
| | | */ |
| | | public Boolean[] isThisProtocolHead(byte[] bs) throws Exception{ |
| | |
| | | int len = ByteUtilUnsigned.byte2Byte(bs, ProtocolConstantV206V1.dataLenIndex); |
| | | return len + ProtocolConstantV206V1.lenHead2ctrl + ProtocolConstantV206V1.lenTail; |
| | | }else{ |
| | | int len = ByteUtilUnsigned.bytes2Short_LE(bs, ProtocolConstantV206V1.UG_dataLenIndex_start); |
| | | int len = ByteUtilUnsigned.bytes2Short_BE(bs, ProtocolConstantV206V1.UG_dataLenIndex_start); |
| | | return len + ProtocolConstantV206V1.UG_lenHead2Cmd + ProtocolConstantV206V1.UG_lenTail; |
| | | } |
| | | } |