示例#1
0
def test_xl320_led_packet():
    xl = XL320()
    ans = [255, 255, 253, 0, 1, 6, 0, 3, 25, 0, 1, 47, 98]
    pkt = xl.makeLEDPacket(1, XL320.LED_RED)
    # print(ans)
    # print(pkt)
    packet_check(ans, pkt)
示例#2
0
def test_xl320_reset_packet():
    xl = XL320()
    ans = [255, 255, 253, 0, 1, 4, 0, 6, 1, 161, 230]
    pkt = xl.makeResetPacket(1, 2)
    # print(ans)
    # print(pkt)
    packet_check(ans, pkt)
示例#3
0
def test_error_packet():
    xl = XL320()

    pkt = [255, 255, 253, 0, 1, 4, 0, 85, 0, 161, 12]

    with pytest.raises(Exception):
        assert getPacketType(pkt) == 0x55
示例#4
0
def test_xl320_angle_packet():
    xl = XL320()
    ans = [255, 255, 253, 0, 1, 7, 0, 3, 30, 0, 139, 1, 83, 255]
    pkt = xl.makeServoMovePacket(1, 116)
    # print('\n')
    # print(ans)
    # print(pkt)
    packet_check(ans, pkt)
示例#5
0
def test_xl320_crc16():
    xl = XL320()
    pkt = [
        0xff, 0xff, 0xfd, 0x00, 0x01, 0x07, 0x00, 0x02, 0x63, 0x02, 0x04, 0x00,
        0x1b, 0xf9
    ]
    ans = xl.check_sum(pkt[:-2])  # you don't count the crc
    b = le(ans)
    assert b == [0x1b, 0xf9]
示例#6
0
def test_xl320_find_pkts():
    xl = XL320()
    err = [
        0, 255, 255, 253, 0, 1, 4, 0, 85, 0, 161, 12, 0, 4, 0, 255, 255, 253,
        0, 1, 4, 0, 85, 128, 162, 143, 0, 0
    ]
    pkts = xl.decodePacket(err)
    assert len(pkts) == 2

    err = [0, 1, 4, 0, 85, 0, 161, 12, 0, 4, 0, 255, 255, 253]
    pkts = xl.decodePacket(err)
    assert len(pkts) == 0
示例#7
0
def test_xl320_reboot_packet():
    xl = XL320()
    ans = [255, 255, 253, 0, 1, 3, 0, 8, 47, 78]
    pkt = xl.makeRebootPacket(1)
    packet_check(ans, pkt)
示例#8
0
def test_xl320_ping_packet():
    xl = XL320()
    ans = [255, 255, 253, 0, 254, 3, 0, 1, 49, 66]
    pkt = xl.makePingPacket()
    packet_check(ans, pkt)