[SOLVED] CRC16 calculations

3 thoughts on “[SOLVED] CRC16 calculations

  1. Does anyone have a formula for calculating the CRC to match the one used by the script engine when it replies to LCSCRIPT commands? The document says:


    Note: CRC16 is calculated using the standard reversed CRC16-CCITT
    x^16+x^12+x^5+1 polynomial (0x1021 representation reversed) with initial value


    Though no matter what I do I cannot figure out how to do it to get the same result. Basically, what I want to do is check if any of the scripts on the device are outdated so I can upload new ones. 

    1. My colleague Luca T. reports that this library is producing the same CRC:


      We had used
      the following Python module


      We had used the crcmod
      1.4 version, but more recent version is available now

      Enclosed you can
      find the script (crc16.py) for tests using the crcmod 1.4 version.

      works with recent Python versions not for 1.5.2+ version installed with




      import crcmod

      crc16 = crcmod.mkCrcFun(0x11021, 0xffff, True)

      f = open("D:/transito/script_pyo/pystone.pyo", "rb")
      data = f.read()
      crc = crc16(data)
      print hex(crc)