TinLethax

Tektronix DPO/MSO2000 calibration data checksum calculation

Sep 29th, 2025
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | Source Code | 0 0
  1.                     // read first two byte -> stored checksum
  2.     fread(u16ChecksumStored,2,1,calFileHandler);
  3.     u32Mod7Counter = 0;
  4.                     // read until the end of file
  5.     while (sVar2 = fread(u8ReadBuffer,1,1,calFileHandler), sVar2 == 1) {
  6.       u32Mod7 = u32Mod7Counter & 0b00000111;
  7.       u32Mod7Counter = u32Mod7Counter + 1;
  8.       u32SumAccumulator =
  9.            u32SumAccumulator +
  10.            (u8ReadBuffer[0] << u32Mod7) + (u8ReadBuffer[0] >> (7 - u32Mod7 & 0b00111111));
  11.     }
  12.                     // cast to uint16_t
  13.     *u16ChecksumCalculated = u32SumAccumulator._2_2_;
  14.     if (*u16ChecksumCalculated == *u16ChecksumStored) {
  15.       isChecksumMatch = 1;
  16.     }
  17.     else {
  18.       isChecksumMatch = 0;
  19.     }
  20.   }
  21.   return isChecksumMatch;
Advertisement
Add Comment
Please, Sign In to add comment