Exemplo n.º 1
0
def test_crc16():
    pkt = [
        0xff, 0xff, 0xfd, 0x00, 0x01, 0x07, 0x00, 0x02, 0x63, 0x02, 0x04, 0x00,
        0x1b, 0xf9
    ]
    ans = crc16(pkt[:-2])  # you don't count the crc
    b = le(ans)
    assert b == [0x1b, 0xf9]
Exemplo n.º 2
0
def getSingle(ID, ser):
    pkt = makeReadPacket(ID, 37, le(2))
    # print('made packet:', pkt)
    ID = None
    angle = None

    ans = ser.sendPkt(pkt)
    if ans:
        ans = ans[0]
        ID, angle = getInfo(ans)

    return angle
Exemplo n.º 3
0
def getSingle(ID, ser):
	pkt = makeReadPacket(ID, 37, le(2))
	# print('made packet:', pkt)
	ID = None
	angle = None

	ans = ser.sendPkt(pkt)
	if ans:
		ans = ans[0]
		ID, angle = getInfo(ans)

	return ID, angle
Exemplo n.º 4
0
def getSingle(ID, ser):
    pkt = makeReadPacket(ID, 37, le(50 - 37 + 1))
    # print('made packet:', pkt)

    ans = ser.sendPkt(pkt)
    if ans:
        ans = ans[0]
        pd = PacketDecoder(ans, 37)  # data packet starts at register 37
        # pd.printPacket()
        if pd.checkError():
            raise Exception('Crap!')
        ans = pktToDict(pd)
    else:
        ans = None

    return ans
Exemplo n.º 5
0
def getSingle(ID, ser):
	pkt = makeReadPacket(ID, 37, le(50-37+1))
	# print('made packet:', pkt)

	ans = ser.sendPkt(pkt)
	if ans:
		ans = ans[0]
		pd = PacketDecoder(ans, 37)  # data packet starts at register 37
		# pd.printPacket()
		if pd.checkError():
			raise Exception('Crap!')
		ans = pktToDict(pd)
	else:
		ans = None

	return ans