Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // read first two byte -> stored checksum
- fread(u16ChecksumStored,2,1,calFileHandler);
- u32Mod7Counter = 0;
- // read until the end of file
- while (sVar2 = fread(u8ReadBuffer,1,1,calFileHandler), sVar2 == 1) {
- u32Mod7 = u32Mod7Counter & 0b00000111;
- u32Mod7Counter = u32Mod7Counter + 1;
- u32SumAccumulator =
- u32SumAccumulator +
- (u8ReadBuffer[0] << u32Mod7) + (u8ReadBuffer[0] >> (7 - u32Mod7 & 0b00111111));
- }
- // cast to uint16_t
- *u16ChecksumCalculated = u32SumAccumulator._2_2_;
- if (*u16ChecksumCalculated == *u16ChecksumStored) {
- isChecksumMatch = 1;
- }
- else {
- isChecksumMatch = 0;
- }
- }
- return isChecksumMatch;
Advertisement
Add Comment
Please, Sign In to add comment