Exemplo n.º 1
0
def interrogator(msg):
    """Decode interrogator identifier code.

    Args:
        msg (str): 14 hexdigits string
    Returns:
        int: interrogator identifier code

    """
    # simply the CRC reminder
    return common.crc(msg)
Exemplo n.º 2
0
 def check_msg(self, msg):
     df = common.df(msg)
     msglen = len(msg)
     if df == 17 and msglen == 28:
         if common.crc(msg) == 0:
             return True
     elif df in [20, 21] and msglen == 28:
         return True
     elif df in [4, 5, 11] and msglen == 14:
         return True
     else:
         return False
Exemplo n.º 3
0
def interrogator(msg):
    """Decode interrogator identifier code.

    Args:
        msg (str): 14 hexdigits string
    Returns:
        int: interrogator identifier code

    """
    # the CRC remainder contains the CL and IC field. top three bits are CL field and last four bits are IC field.
    remainder = common.crc(msg)
    if remainder > 79: 
        IC = "corrupt IC"
    elif remainder < 16:
        IC="II"+str(remainder)
    else:
        IC="SI"+str(remainder-16)
    return IC
Exemplo n.º 4
0
def test_crc_decode():
    checksum = common.crc("8D406B902015A678D4D220AA4BDA")
    assert checksum == "000000000000000000000000"
Exemplo n.º 5
0
def test_crc_encode():
    parity = common.crc("8D406B902015A678D4D220AA4BDA", encode=True)
    assert common.hex2bin("AA4BDA") == parity
Exemplo n.º 6
0
def test_crc_decode():
    assert common.crc_legacy("8D406B902015A678D4D220AA4BDA") == 0

    assert common.crc("8D406B902015A678D4D220AA4BDA") == 0
    assert common.crc("8d8960ed58bf053cf11bc5932b7d") == 0
    assert common.crc("8d45cab390c39509496ca9a32912") == 0
    assert common.crc("8d49d3d4e1089d00000000744c3b") == 0
    assert common.crc("8d74802958c904e6ef4ba0184d5c") == 0
    assert common.crc("8d4400cd9b0000b4f87000e71a10") == 0
    assert common.crc("8d4065de58a1054a7ef0218e226a") == 0

    assert common.crc("c80b2dca34aa21dd821a04cb64d4") == 10719924
    assert common.crc("a800089d8094e33a6004e4b8a522") == 4805588
    assert common.crc("a8000614a50b6d32bed000bbe0ed") == 5659991
    assert common.crc("a0000410bc900010a40000f5f477") == 11727682
    assert common.crc("8d4ca251204994b1c36e60a5343d") == 16
    assert common.crc("b0001718c65632b0a82040715b65") == 353333
Exemplo n.º 7
0
def test_crc_encode():
    parity = common.crc("8D406B902015A678D4D220AA4BDA", encode=True)
    assert common.int2hex(parity) == "AA4BDA"