import CRCCCITT


def main():
  buff = [0x11,0x03,0x00,0x01]
  crc = RTM64CRC16(buff, 4)
  print(hex(crc))
  crc_CCITT = CRCCCITT.CRCCCITT()
  temp_buff = bytearray(buff[0:]) 
  print(temp_buff)
  crc = crc_CCITT.calculate(temp_buff)
  print(hex(crc))
  
def RTM64CRC16(pbuffer, Len):
  """CRC16 for RTM64"""
  CRC = 0x0000
  k = 0
  while (k < Len):
    CRC = (CRC ^ ((pbuffer[k] << 8) & 0xFFFF))
    k += 1
    i = 8
    while (i):
      i -= 1
      if (CRC & 0x8000):
        CRC = (((CRC << 1) & 0xFFFF) ^ 0x1021)
      else:
        CRC = ((CRC << 1) & 0xFFFF)
  return CRC
if __name__=="__main__":
  main()
97cd6e628f3276809a1f4c8aa0e6d78641dabf90
<mask token>


def RTM64CRC16(pbuffer, Len):
    """CRC16 for RTM64"""
    CRC = 0
    k = 0
    while k < Len:
        CRC = CRC ^ pbuffer[k] << 8 & 65535
        k += 1
        i = 8
        while i:
            i -= 1
            if CRC & 32768:
                CRC = CRC << 1 & 65535 ^ 4129
            else:
                CRC = CRC << 1 & 65535
    return CRC


<mask token>

<mask token>


def main():
    buff = [17, 3, 0, 1]
    crc = RTM64CRC16(buff, 4)
    print(hex(crc))
    crc_CCITT = CRCCCITT.CRCCCITT()
    temp_buff = bytearray(buff[0:])
    print(temp_buff)
    crc = crc_CCITT.calculate(temp_buff)
    print(hex(crc))


def RTM64CRC16(pbuffer, Len):
    """CRC16 for RTM64"""
    CRC = 0
    k = 0
    while k < Len:
        CRC = CRC ^ pbuffer[k] << 8 & 65535
        k += 1
        i = 8
        while i:
            i -= 1
            if CRC & 32768:
                CRC = CRC << 1 & 65535 ^ 4129
            else:
                CRC = CRC << 1 & 65535
    return CRC


<mask token>

<mask token>


def main():
    buff = [17, 3, 0, 1]
    crc = RTM64CRC16(buff, 4)
    print(hex(crc))
    crc_CCITT = CRCCCITT.CRCCCITT()
    temp_buff = bytearray(buff[0:])
    print(temp_buff)
    crc = crc_CCITT.calculate(temp_buff)
    print(hex(crc))


def RTM64CRC16(pbuffer, Len):
    """CRC16 for RTM64"""
    CRC = 0
    k = 0
    while k < Len:
        CRC = CRC ^ pbuffer[k] << 8 & 65535
        k += 1
        i = 8
        while i:
            i -= 1
            if CRC & 32768:
                CRC = CRC << 1 & 65535 ^ 4129
            else:
                CRC = CRC << 1 & 65535
    return CRC


if __name__ == '__main__':
    main()

import CRCCCITT


def main():
    buff = [17, 3, 0, 1]
    crc = RTM64CRC16(buff, 4)
    print(hex(crc))
    crc_CCITT = CRCCCITT.CRCCCITT()
    temp_buff = bytearray(buff[0:])
    print(temp_buff)
    crc = crc_CCITT.calculate(temp_buff)
    print(hex(crc))


def RTM64CRC16(pbuffer, Len):
    """CRC16 for RTM64"""
    CRC = 0
    k = 0
    while k < Len:
        CRC = CRC ^ pbuffer[k] << 8 & 65535
        k += 1
        i = 8
        while i:
            i -= 1
            if CRC & 32768:
                CRC = CRC << 1 & 65535 ^ 4129
            else:
                CRC = CRC << 1 & 65535
    return CRC


if __name__ == '__main__':
    main()

import CRCCCITT


def main():
  buff = [0x11,0x03,0x00,0x01]
  crc = RTM64CRC16(buff, 4)
  print(hex(crc))
  crc_CCITT = CRCCCITT.CRCCCITT()
  temp_buff = bytearray(buff[0:]) 
  print(temp_buff)
  crc = crc_CCITT.calculate(temp_buff)
  print(hex(crc))
  
def RTM64CRC16(pbuffer, Len):
  """CRC16 for RTM64"""
  CRC = 0x0000
  k = 0
  while (k < Len):
    CRC = (CRC ^ ((pbuffer[k] << 8) & 0xFFFF))
    k += 1
    i = 8
    while (i):
      i -= 1
      if (CRC & 0x8000):
        CRC = (((CRC << 1) & 0xFFFF) ^ 0x1021)
      else:
        CRC = ((CRC << 1) & 0xFFFF)
  return CRC
if __name__=="__main__":
  main()