| | |
| | | this.reg_count = reg_count;
|
| | | }
|
| | |
|
| | | public void mkBusRtu(int addr,int Cmd,int reg_addr,int reg_count) {
|
| | | this.addr = addr;
|
| | | this.Cmd = Cmd;
|
| | | this.reg_addr = reg_addr;
|
| | | this.reg_count = reg_count;
|
| | | }
|
| | | |
| | | public void clear() {
|
| | | this.addr = 0; //设备地址
|
| | | this.Cmd = 0; //功能码
|
| | |
| | | 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);
|
| | | }
|
| | | |
| | | }
|