Exemplo n.º 1
0
def test_frame_from_bytes():
    # 03 67 01 10 05 67 00 FF = 27.2C + 25.5C
    buf = bytes([0x03, 0x67, 0x01, 0x10, 0x05, 0x67, 0x00, 0xff])
    frame = LppFrame.from_bytes(buf)
    assert buf == bytes(frame)
    assert buf == frame.to_bytes()
    assert len(frame) == 2
    # 01 67 FF D7
    buf = bytes([0x01, 0x67, 0xFF, 0xD7])
    frame = LppFrame.from_bytes(buf)
    assert buf == bytes(frame)
    assert buf == frame.to_bytes()
    assert len(frame) == 1
    # 06 71 04 D2 FB 2E 00 00
    buf = bytes([0x06, 0x71, 0x04, 0xD2, 0xFB, 0x2E, 0x00, 0x00])
    frame = LppFrame.from_bytes(buf)
    assert buf == bytes(frame)
    assert buf == frame.to_bytes()
    assert len(frame) == 1
    # 01 88 06 76 5f f2 96 0a 00 03 e8
    buf = bytes(
        [0x01, 0x88, 0x06, 0x76, 0x5f, 0xf2, 0x96, 0x0a, 0x00, 0x03, 0xe8])
    frame = LppFrame.from_bytes(buf)
    assert buf == bytes(frame)
    assert buf == frame.to_bytes()
    assert len(frame) == 1
Exemplo n.º 2
0
def test_frame_from_bytes():
    # 03 67 01 10 05 67 00 FF = 27.2C + 25.5C
    buf = bytearray([0x03, 0x67, 0x01, 0x10, 0x05, 0x67, 0x00, 0xff])
    frame = LppFrame.from_bytes(buf)
    assert buf == frame.bytes()
    assert len(frame) == 2
Exemplo n.º 3
0
def test_frame_from_bytes_base64():
    base64_str = "AYgILMMBiIMAAAACAAY="
    frame = LppFrame.from_bytes(base64.decodebytes(base64_str.encode('ascii')))
    assert len(frame) == 2