CRC-CCITT 16-bit Python Manual Calculation

前端 未结 7 1195
情深已故
情深已故 2021-02-06 10:48

Problem

I am writing code for an embedded device. A lot of solutions out there for CRC-CCITT 16-bit calculations require libraries.

Given that u

7条回答
  •  广开言路
    2021-02-06 11:15

    I have developed a small python module to generate crc. Give it a shot and check the source code it may help!

    https://github.com/killercode/PythonCRC

    For what you want you just need to use the following code

    import crc
    
    crccalc = crc.Crc()
    crccalc.setCRCccitt()  # Let's calculate the CRC CCITT of a value
    crccalc.data = "My Data"
    crccalc.compute()
    print crccalc.result
    

    Hope it helps :)

提交回复
热议问题