| | |
| | | |
| | | MidResultToRtu midRs = new MidResultToRtu() ; |
| | | midRs.protocolName = para.protocolName ;//协议名称 |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtu地址(电信平台设备IMEI) |
| | | midRs.rtuAddr = para.rtuAddr ;//Rtu地址 |
| | | midRs.commandId = para.commandId ;//命令ID,发起命令的客户端(web端)生成,以匹配命令结果 |
| | | midRs.downCode = para.commandCode ;//下行命令功能码; |
| | | midRs.downBuffer = bs ;//下行命令数据 |
| | |
| | | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = commonV1_0_1.createCtrl((byte)0) ; |
| | | bsHead[index] = commonV1_0_1.createCtrl((byte)0, (byte)0) ; |
| | | |
| | | index++ ; |
| | | GlCreate.createRtuAddr(para.rtuAddr, bsHead, index); |
| | |
| | | |
| | | GlCreate.createLen(bytes);//长度放字节数组中 |
| | | |
| | | bytes = GlCreate.createCrcTail(bytes) ;//CRC和尾叠加字节数组中 |
| | | byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC和尾叠加字节数组中 |
| | | |
| | | bytes = ByteUtil.bytesMerge(bytes, bsTail) ; |
| | | |
| | | return bytes ; |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception{ |
| | | ParseParamsForDownV1_0_1 p = new ParseParamsForDownV1_0_1() ; |
| | | p.commandCode = "02" ; |
| | | p.rtuAddr = "9672950001"; |
| | | |
| | | Cd_02_Down obj = new Cd_02_Down() ; |
| | | byte[] bs = obj.doParse(p) ; |
| | | |
| | | String hex1 = ByteUtil.bytes2Hex(bs,true) ; |
| | | String hex2 = ByteUtil.bytes2Hex(bs,false) ; |
| | | |
| | | System.out.println(hex1); |
| | | System.out.println(hex2); |
| | | } |
| | | |
| | | } |