示例#1
0
    def test_calculate3_004(self):
        data = NumberMask(0x1000, 16)
        crcSize = 16
        inputPoly = NumberMask(0x10001, crcSize)
        regInit = 0x0
        xorOut = 0x0
        reverse = False

        crcProc = HwCRC()
        crcProc.setReversed(reverse)
        crcProc.setXorOutValue(xorOut)
        crcProc.setInitCRC(regInit, crcSize)

        crc = crcProc.calculate3(data, inputPoly)

        #         print "values: {} poly:{:X} init:{:X} xorOut:{:08b} rev:{} crc:{:08b} crcmod:{:08b} crcxor:{:08b}".format( data, inputPoly, regInit, xorOut, reverse, crc, crcLib, crc^crcLib )
        self.assertEqual(crc, 0x1000)
示例#2
0
    def test_calculate3_c16_d80(self):
        data = NumberMask(0x8E843664A9CB222CE7EC, 80)
        crcSize = 16
        inputPoly = NumberMask(0x1ABCD, crcSize)
        regInit = 0x0
        xorOut = 0x0
        reverse = False

        #         masterPoly = inputPoly.masterData()
        #         crc_func = crcmod.mkCrcFun(masterPoly, rev=reverse, initCrc=regInit, xorOut=xorOut)
        #         crcLib  = crc_func( data.toASCII() )
        # #         print "crc: {:X}".format( crcLib )

        crcProc = HwCRC()
        crcProc.setReversed(reverse)
        crcProc.setXorOutValue(xorOut)
        crcProc.setInitCRC(regInit, crcSize)

        crc = crcProc.calculate3(data, inputPoly)

        #         print "values: {} poly:{:X} init:{:X} xorOut:{:08b} rev:{} crc:{:08b} crcmod:{:08b} crcxor:{:08b}".format( data, inputPoly, regInit, xorOut, reverse, crc, crcLib, crc^crcLib )
        #         self.assertEqual( crc, crcLib )
        self.assertEqual(crc, 0xD36F)