Module: CRC16

Defined in:
lib/ruby-sml/crc16.rb

Overview

Class Method Summary collapse

Class Method Details

.crc16(buf, crc = 0xffff) ⇒ Object



5
6
7
8
# File 'lib/ruby-sml/crc16.rb', line 5

def self.crc16(buf, crc=0xffff)
  buf.each_byte{|x| crc = (crc >> 8) ^ CCITT_16[(crc ^ x) & 0xff]}
  return crc
end