Skip to content
Snippets Groups Projects
Commit 5092a1fc authored by Benjamin Koch's avatar Benjamin Koch
Browse files

only print CRC when it is wrong

parent b816fbcf
No related branches found
No related tags found
No related merge requests found
......@@ -534,13 +534,14 @@ impl RS485 {
}
if let ModbusFrameLength::Length(x) = rx_expected_bytes {
if x == rx_received_bytes {
let received_crc = rx_char_prev as u16 | ((rx_char as u16) << 8);
let calculated_crc = rxcrc.finalize();
rxcrc = CRC.digest();
info!("received_crc: {:04x}, calculated_crc: {:04x}", received_crc, calculated_crc);
rxcrc = CRC.digest(); // re-init to placate borrow checker
const CORRECT_CRC: u16 = 0; // because we include the CRC bytes in our calculation
if calculated_crc != CORRECT_CRC {
info!("CRC: {:04x} (should be zero)", calculated_crc);
}
//FIXME In case of CRC mismatch, wait for gap/idle of >=1.5 chars.
const CORRECT_CRC: u16 = 0; // because we include the CRC bytes in our calculation
const OUR_ADDRESS: u8 = 1;
if rxbuf[0] == OUR_ADDRESS && calculated_crc == CORRECT_CRC {
txbuf.clear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment