예제 #1
0
 def test02(self):
     data = 100*"1"
     expected_result = 2326594156
     result = digital.crc32(data)
     #print hex(result)
     
     self.assertEqual(expected_result, result)
예제 #2
0
    def test03(self):
        data = 10*"0123456789"
        expected_result = 3774345973
        result = digital.crc32(data)
        #print hex(result)

        self.assertEqual(expected_result, result)
예제 #3
0
    def test03 (self):
        data = 10*"0123456789"
        expected_result = 3774345973
        result = digital_swig.crc32(data)
        #print hex(result)

        self.assertEqual (expected_result, result)
예제 #4
0
 def test01(self):
     data = 100*"0"
     expected_result = 2943744955
     result = digital.crc32(data)
     #print hex(result)
     
     self.assertEqual(expected_result, result)
예제 #5
0
 def test02 (self):
     data = 100*"1"
     expected_result = 2326594156
     result = digital_swig.crc32(data)
     #print hex(result)
     
     self.assertEqual (expected_result, result)
예제 #6
0
 def test01 (self):
     data = 100*"0"
     expected_result = 2943744955
     result = digital_swig.crc32(data)
     #print hex(result)
     
     self.assertEqual (expected_result, result)
예제 #7
0
파일: crc.py 프로젝트: Jhr-Ronyo/gnuradio-1
def check_crc32(s):
    if len(s) < 4:
        return (False, '')
    msg = s[:-4]
    #print "msg = '%s'" % (msg,)
    actual = digital_swig.crc32(msg)
    (expected,) = struct.unpack(">I", s[-4:])
    # print "actual =", hex(actual), "expected =", hex(expected)
    return (actual == expected, msg)
예제 #8
0
def check_crc32(s):
    if len(s) < 4:
        return (False, '')
    msg = s[:-4]
    #print "msg = '%s'" % (msg,)
    actual = digital_swig.crc32(msg)
    (expected, ) = struct.unpack(">I", s[-4:])
    # print "actual =", hex(actual), "expected =", hex(expected)
    return (actual == expected, msg)
예제 #9
0
def check_crc32(s):
    if len(s) < 4:
        return (False, '')
    msg = s[:-4]
    cbits = 0
    #print "msg = '%s'" % (msg,)
    actual = digital.crc32(msg)
    bin_actual = bin(actual)
    (expected,) = struct.unpack(">I", s[-4:])
    bin_expected = bin(expected)
  #  print bin_expected
   # print bin_actual
    #print max(len(bin_actual),len(bin_expected))-2
    for i in range(max(len(bin_actual),len(bin_expected))-2):
	if bin_expected[i+2:i+3]==bin_actual[i+2:i+3]:
	    cbits=cbits+1
    #print cbits,len(bin_actual)
    # print "actual =", hex(actual), "expected =", hex(expected)
    return (actual == expected, msg, cbits, len(bin_actual)-2)
예제 #10
0
파일: crc.py 프로젝트: Jhr-Ronyo/gnuradio-1
def gen_and_append_crc32(s):
    crc = digital_swig.crc32(s)
    return s + struct.pack(">I", gru.hexint(crc) & 0xFFFFFFFF)
예제 #11
0
def gen_and_append_crc32(s):
    crc = digital_swig.crc32(s)
    return s + struct.pack(">I", gru.hexint(crc) & 0xFFFFFFFF)