Compare commits
2 Commits
137c8328f3
...
f5d777d945
| Author | SHA1 | Date | |
|---|---|---|---|
| f5d777d945 | |||
| c76996ceb7 |
@@ -188,7 +188,7 @@ impl Protocol300Message {
|
|||||||
return Err(MessageDecodingError::LengthMismatch());
|
return Err(MessageDecodingError::LengthMismatch());
|
||||||
}
|
}
|
||||||
|
|
||||||
let message_identifier = match MessageIdentifier::try_from(bytes[2] & 0x0F) {
|
let message_identifier = match MessageIdentifier::try_from(bytes[2]) {
|
||||||
Ok(id) => id,
|
Ok(id) => id,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to decode message: invalid message identifier byte 0x{:02X}", bytes[2]);
|
error!("Failed to decode message: invalid message identifier byte 0x{:02X}", bytes[2]);
|
||||||
@@ -196,7 +196,7 @@ impl Protocol300Message {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let function_code = match FunctionCode::try_from(bytes[3] & 0x0F) {
|
let function_code = match FunctionCode::try_from(bytes[3]) {
|
||||||
Ok(fc) => fc,
|
Ok(fc) => fc,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to decode message: invalid function code byte 0x{:02X}", bytes[3]);
|
error!("Failed to decode message: invalid function code byte 0x{:02X}", bytes[3]);
|
||||||
@@ -231,14 +231,14 @@ impl Protocol300Message {
|
|||||||
let checksum = bytes[telegram_length as usize + 2];
|
let checksum = bytes[telegram_length as usize + 2];
|
||||||
|
|
||||||
// Fail if the checksums do not match
|
// Fail if the checksums do not match
|
||||||
// if checksum != checksum_calculated {
|
if checksum != checksum_calculated {
|
||||||
// #[cfg(feature = "log")]
|
#[cfg(feature = "log")]
|
||||||
// error!("Failed to decode message: checksum mismatch - received: 0x{checksum:02X}, calculated: 0x{checksum_calculated:02X}, address: 0x{data_address:04X}, message_id: {message_identifier}, function: {function_code}");
|
error!("Failed to decode message: checksum mismatch - received: 0x{checksum:02X}, calculated: 0x{checksum_calculated:02X}, address: 0x{data_address:04X}, message_id: {message_identifier}, function: {function_code}");
|
||||||
// #[cfg(feature = "defmt")]
|
#[cfg(feature = "defmt")]
|
||||||
// error!("Failed to decode message: checksum mismatch - received: 0x{:02X}, calculated: 0x{:02X}, address: 0x{:04X}, message_id: {}, function: {}", checksum, checksum_calculated, data_address, defmt::Debug2Format(&message_identifier), defmt::Debug2Format(&function_code));
|
error!("Failed to decode message: checksum mismatch - received: 0x{:02X}, calculated: 0x{:02X}, address: 0x{:04X}, message_id: {}, function: {}", checksum, checksum_calculated, data_address, defmt::Debug2Format(&message_identifier), defmt::Debug2Format(&function_code));
|
||||||
|
|
||||||
// return Err(MessageDecodingError::Checksum)
|
return Err(MessageDecodingError::Checksum)
|
||||||
// }
|
}
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
telegram_length,
|
telegram_length,
|
||||||
|
|||||||
Reference in New Issue
Block a user