class F4R::CRC16
See CRC section in the FIT SDK for more info and CRC16
examples.
Public Class Methods
crc(io)
click to toggle source
Compute checksum over given IO.
@param [IO] io
@return [crc] crc
Checksum of lower and upper four bits for all bytes in IO
# File lib/f4r.rb, line 678 def self.crc(io) crc = 0 io.each_byte do |byte| [byte, (byte >> 4)].each do |sb| crc = ((crc >> 4) & 0x0FFF) ^ @@table[(crc ^ sb) & 0xF] end end crc end