|
|
|
|
@ -49,11 +49,13 @@ public class BinaryMessageDecoder {
|
|
|
|
|
|
|
|
|
|
//get crc
|
|
|
|
|
this.crc = Arrays.copyOfRange(this.fullMessage, this.fullMessage.length - 4, fullMessage.length);
|
|
|
|
|
|
|
|
|
|
ByteBuffer bytes = ByteBuffer.allocate(this.header.length + this.message.length);
|
|
|
|
|
bytes.put(this.header);
|
|
|
|
|
bytes.put(this.message);
|
|
|
|
|
|
|
|
|
|
CRC32 crc = new CRC32();
|
|
|
|
|
crc.reset();
|
|
|
|
|
crc.update(this.fullMessage);
|
|
|
|
|
crc.update(bytes.array(), 0, bytes.array().length);
|
|
|
|
|
|
|
|
|
|
//run through the checks
|
|
|
|
|
if (this.message.length != ByteConverter.bytesToShort(this.headerMessageLength)){//keep like this - hba65
|
|
|
|
|
@ -67,11 +69,11 @@ public class BinaryMessageDecoder {
|
|
|
|
|
}else if(this.headerSync2 !=(byte) 0x83){
|
|
|
|
|
System.err.println("Sync byte 2 is wrong: " + this.headerSync2);
|
|
|
|
|
return null;
|
|
|
|
|
}/*else if(crc.getValue() != 0){
|
|
|
|
|
}else if(crc.getValue() != ByteConverter.bytesToLong(this.crc)){
|
|
|
|
|
//todo check crc
|
|
|
|
|
System.err.println("CRC is not 0 and is instead:" + crc.getValue());
|
|
|
|
|
return;
|
|
|
|
|
}*/
|
|
|
|
|
System.err.println("CRC is not "+ByteConverter.bytesToLong(this.crc)+" and is instead:" + crc.getValue());
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageType mType = MessageType.valueOf(this.headerMessageType);
|
|
|
|
|
AC35Data data = null;
|
|
|
|
|
|