forked from M-Labs/artiq-zynq
proto fw: cleanup the crc calculation
This commit is contained in:
parent
0f9be29f4e
commit
8467f2d4f0
|
@ -172,10 +172,8 @@ impl Packet {
|
||||||
writer.write(&data[0..length as usize])?;
|
writer.write(&data[0..length as usize])?;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_packet(&writer.get_ref()[4..writer.position()]);
|
let checksum = (!crc::crc32::checksum_ieee(&writer.get_ref()[4..writer.position()])).swap_bytes();
|
||||||
|
writer.write(&checksum.to_be_bytes())?;
|
||||||
let checksum = crc32::checksum_ieee(&writer.get_ref()[4..writer.position()]);
|
|
||||||
writer.write(&(!checksum).to_le_bytes())?;
|
|
||||||
}
|
}
|
||||||
_ => return Err(Error::UnknownPacket(0)),
|
_ => return Err(Error::UnknownPacket(0)),
|
||||||
}
|
}
|
||||||
|
@ -188,8 +186,8 @@ impl Packet {
|
||||||
| Packet::CtrlWrite { .. }
|
| Packet::CtrlWrite { .. }
|
||||||
| Packet::CtrlReadWithTag { .. }
|
| Packet::CtrlReadWithTag { .. }
|
||||||
| Packet::CtrlWriteWithTag { .. } => {
|
| Packet::CtrlWriteWithTag { .. } => {
|
||||||
let checksum = crc32::checksum_ieee(&writer.get_ref()[4..writer.position()]);
|
let checksum = (!crc::crc32::checksum_ieee(&writer.get_ref()[4..writer.position()])).swap_bytes();
|
||||||
writer.write(&(!checksum).to_le_bytes())?;
|
writer.write(&checksum.to_be_bytes())?;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue