1
0
Fork 0

proto fw: cleanup the crc calculation

This commit is contained in:
morgan 2024-10-03 17:52:26 +08:00
parent 0f9be29f4e
commit 8467f2d4f0
1 changed files with 4 additions and 6 deletions

View File

@ -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())?;
}
_ => {}
}