diff --git a/firmware/rust1/src/rs485.rs b/firmware/rust1/src/rs485.rs index 9c78b1e290a4e89ad8ee85164329269923428f8d..314a0063afff9f1be001d54ca9e96d199016612b 100644 --- a/firmware/rust1/src/rs485.rs +++ b/firmware/rust1/src/rs485.rs @@ -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();