From 9423428bb006fbd104c52a494eb31df79cd3e8d6 Mon Sep 17 00:00:00 2001 From: occheung Date: Mon, 22 Nov 2021 16:53:57 +0800 Subject: [PATCH] drtio: fix crc32 offset address --- artiq/firmware/libboard_artiq/drtioaux.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/artiq/firmware/libboard_artiq/drtioaux.rs b/artiq/firmware/libboard_artiq/drtioaux.rs index f72072702..818775d7b 100644 --- a/artiq/firmware/libboard_artiq/drtioaux.rs +++ b/artiq/firmware/libboard_artiq/drtioaux.rs @@ -137,11 +137,10 @@ pub fn send(linkno: u8, packet: &Packet) -> Result<(), Error> { packet.write_to(&mut writer)?; - let padding = 4 - (writer.position() % 4); - if padding != 4 { - for _ in 0..padding { - writer.write_u8(0)?; - } + // Pad till offset 4, insert checksum there + let padding = (12 - (writer.position() % 8)) % 8; + for _ in 0..padding { + writer.write_u8(0)?; } let checksum = crc::crc32::checksum_ieee(&writer.get_ref()[0..writer.position()]);