From ce5ce8adb8a03a2596e1198a0938d1c2edd6437b Mon Sep 17 00:00:00 2001 From: DELL <1525436766@qq.com> Date: 星期三, 18 十二月 2024 15:24:56 +0800 Subject: [PATCH] crc测试 --- ElectLock_Monitor/src/com/dev/modbus/MyModBusRtu.java | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/ElectLock_Monitor/src/com/dev/modbus/MyModBusRtu.java b/ElectLock_Monitor/src/com/dev/modbus/MyModBusRtu.java index d773b2e..401f557 100644 --- a/ElectLock_Monitor/src/com/dev/modbus/MyModBusRtu.java +++ b/ElectLock_Monitor/src/com/dev/modbus/MyModBusRtu.java @@ -128,4 +128,15 @@ return true; } + public static void main(String[] args) { + byte[] data = new byte[] {(byte) 0xa0 ,(byte)0xdd,0x6c ,0x23,0x26,0x16}; + ByteBuffer bf = ByteBuffer.allocate(data.length); + bf.order(ByteOrder.BIG_ENDIAN); + bf.put(data); + System.out.println(Crc16.CalCRC16(bf, bf.limit())&0xFFFF); + + + System.out.println(Crc16.CalCRC16(data, bf.limit())&0xFFFF); + } + } -- Gitblit v1.9.1