From 8467f2d4f09b1069da4bc490d69cee13c1262377 Mon Sep 17 00:00:00 2001 From: morgan Date: Thu, 3 Oct 2024 17:52:26 +0800 Subject: [PATCH] proto fw: cleanup the crc calculation --- src/libboard_artiq/src/cxp_proto.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/libboard_artiq/src/cxp_proto.rs b/src/libboard_artiq/src/cxp_proto.rs index 69223a3..5e5c32f 100644 --- a/src/libboard_artiq/src/cxp_proto.rs +++ b/src/libboard_artiq/src/cxp_proto.rs @@ -172,10 +172,8 @@ impl Packet { writer.write(&data[0..length as usize])?; } - print_packet(&writer.get_ref()[4..writer.position()]); - - let checksum = crc32::checksum_ieee(&writer.get_ref()[4..writer.position()]); - writer.write(&(!checksum).to_le_bytes())?; + let checksum = (!crc::crc32::checksum_ieee(&writer.get_ref()[4..writer.position()])).swap_bytes(); + writer.write(&checksum.to_be_bytes())?; } _ => return Err(Error::UnknownPacket(0)), } @@ -188,8 +186,8 @@ impl Packet { | Packet::CtrlWrite { .. } | Packet::CtrlReadWithTag { .. } | Packet::CtrlWriteWithTag { .. } => { - let checksum = crc32::checksum_ieee(&writer.get_ref()[4..writer.position()]); - writer.write(&(!checksum).to_le_bytes())?; + let checksum = (!crc::crc32::checksum_ieee(&writer.get_ref()[4..writer.position()])).swap_bytes(); + writer.write(&checksum.to_be_bytes())?; } _ => {} }