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]
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
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
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
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