forked from M-Labs/artiq
1
0
Fork 0

drtio: fix crc32 offset address

This commit is contained in:
occheung 2021-11-22 16:53:57 +08:00 committed by Sébastien Bourdeauducq
parent 7307b30213
commit 9423428bb0
1 changed files with 4 additions and 5 deletions

View File

@ -137,11 +137,10 @@ pub fn send(linkno: u8, packet: &Packet) -> Result<(), Error<!>> {
packet.write_to(&mut writer)?; packet.write_to(&mut writer)?;
let padding = 4 - (writer.position() % 4); // Pad till offset 4, insert checksum there
if padding != 4 { let padding = (12 - (writer.position() % 8)) % 8;
for _ in 0..padding { for _ in 0..padding {
writer.write_u8(0)?; writer.write_u8(0)?;
}
} }
let checksum = crc::crc32::checksum_ieee(&writer.get_ref()[0..writer.position()]); let checksum = crc::crc32::checksum_ieee(&writer.get_ref()[0..writer.position()]);