def main(): #ncp16 & 2 bytes #message = [0x1, 0x5d] message = [0x09, 0x20, 0x0e, 0x05, 0x18, 0x26, 0x09, 0x0a, 0x01] message = [0x09, 0x2a, 0x0e, 0x05, 0x18, 0x26, 0x09, 0x0a, 0x01] message = [0x09, 0x34, 0x0e, 0x05, 0x18, 0x26, 0x09, 0x0a, 0x01] #message = [0, 0xF8] #message = reverse_bits(message) crc_bit, crc_int = ncp16(message) print 'CRC bit: %s' % crc_bit print 'CRC int: %s' % crc_int print byteify(crc_bit)
def test_message5(self): crc_bit, crc_int = ncp16(self.message5) self.assertListEqual(byteify(crc_bit), [0xA2, 0x70])
def test_message4(self): crc_bit, crc_int = ncp16(self.message4) self.assertListEqual(byteify(crc_bit), [0x80, 0x72])
def test_message3(self): crc_bit, crc_int = ncp16(self.message3) self.assertListEqual(byteify(crc_bit), [0x7F, 0x8B])
def test_message2(self): crc_bit, crc_int = ncp16(self.message2) self.assertListEqual(byteify(crc_bit), [0x00, 0x60])
def test_message1(self): crc_bit, crc_int = ncp16(self.message1) self.assertListEqual(byteify(crc_bit), [0xB8, 0xF0])