Exemplo n.º 1
0
    def test03(self):
        data = 10 * "0123456789"
        expected_result = 3774345973
        result = digital.crc32(data)
        #print hex(result)

        self.assertEqual(expected_result, result)
Exemplo n.º 2
0
    def test01(self):
        data = 100 * "0"
        expected_result = 2943744955
        result = digital.crc32(data)
        #print hex(result)

        self.assertEqual(expected_result, result)
Exemplo n.º 3
0
    def test02(self):
        data = 100 * "1"
        expected_result = 2326594156
        result = digital.crc32(data)
        #print hex(result)

        self.assertEqual(expected_result, result)
Exemplo n.º 4
0
 def test02(self):
     data = 100*"1"
     expected_result = 2326594156
     result = digital.crc32(data)
     #print hex(result)
     
     self.assertEqual(expected_result, result)
Exemplo n.º 5
0
    def test03(self):
        data = 10*"0123456789"
        expected_result = 3774345973
        result = digital.crc32(data)
        #print hex(result)

        self.assertEqual(expected_result, result)
Exemplo n.º 6
0
 def test01(self):
     data = 100*"0"
     expected_result = 2943744955
     result = digital.crc32(data)
     #print hex(result)
     
     self.assertEqual(expected_result, result)
Exemplo n.º 7
0
 def rx_is_success(self, decodeOut):
     crc = digital.crc32(decodeOut)
     is_success = (crc == self.curCrc32)
     if is_success:
         print "decoding success!\n"
     else:
         print "decoding not done yet...\n"
     return is_success
Exemplo n.º 8
0
 def tx_set_pkt(self, packet):
     self.encoder.setPacket(packet)
     self.curPacket = packet
     self.curCrc32 = digital.crc32(packet)
     self.tx_done = False
     
     if self.verbosity >= 3:
         self.print_pkt(packet)
 def rx_is_success(self, decodeOut):
     crc = digital.crc32(decodeOut)
     is_success = (crc == self.curCrc32)
     if is_success:
         print "decoding success!\n"
     else:
         print "decoding not done yet...\n"
     return is_success
Exemplo n.º 10
0
def check_crc32(s):
    if len(s) < 4:
        return (False, '')
    msg = s[:-4]
    #print "msg = '%s'" % (msg,)
    actual = digital.crc32(msg)
    (expected,) = struct.unpack(">I", s[-4:])
    # print "actual =", hex(actual), "expected =", hex(expected)
    return (actual == expected, msg)
Exemplo n.º 11
0
def check_crc32(s):
    if len(s) < 4:
        return (False, '')
    msg = s[:-4]
    #print "msg = '%s'" % (msg,)
    actual = digital.crc32(msg)
    (expected, ) = struct.unpack(">I", s[-4:])
    # print "actual =", hex(actual), "expected =", hex(expected)
    return (actual == expected, msg)
Exemplo n.º 12
0
def gen_and_append_crc32(s):
    crc = digital.crc32(s)
    return s + struct.pack(">I", gru.hexint(crc) & 0xFFFFFFFF)
Exemplo n.º 13
0
def gen_and_append_crc32(s):
    crc = digital.crc32(s)
    return s + struct.pack(">I", gru.hexint(crc) & 0xFFFFFFFF)
 def tx_set_pkt(self, packet):
     self.encoder.setPacket(packet)
     self.curPacket = packet
     self.curCrc32 = digital.crc32(packet)
     self.tx_done = False