-
Notifications
You must be signed in to change notification settings - Fork 8
Incorrect CRC equation #1
Copy link
Copy link
Open
Description
The equation for calculating CRC for each record is incorrect in the code. From ruby_extensions.rb, this is the current CRC equation:
crc = RTP::CRC_SEED
self.each_codepoint do |byte|
crc = RTP::CRC_TABLE[(crc ^ byte) & 0xff] ^ (crc >> 8)
end
return crc
With CRC_SEED and CRC_TABLE stored in constants.rb. However, the Elekta documentation (in Appendix A) in this repository gives an equation that is slightly different (in C)
LED17001.pdf
while(len--)
seed = crc_tbl[*((unsigned char *) buf)++ ^ (unsigned char) seed] ^(unsigned char) (seed >> 8)
Based on this, the new Ruby code should be the following, switching crc and byte within the CRC_TABLE argument
crc = RTP::CRC_SEED
self.each_codepoint do |byte|
crc = RTP::CRC_TABLE[(byte ^ crc) & 0xff] ^ (crc >> 8)
end
return crc
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels