class SerialMgr(): def __init__(self): # Create protocol and give callback function self.protocol = Protocol(self.on_new_payload) # Create serial port manager self.serial = SerialPort(self.on_rx_data) self.serial.connect("COM5",115200) self.serial.run() def on_rx_data(self,c): print(c) self.protocol.decode(c) def on_new_payload(self,payload): print("decoded :",payload)
class SerialMgr(): def __init__(self): # Create protocol and give callback function self.protocol = Protocol(self.on_new_payload) # Create serial port manager self.serial = SerialPort(self.on_rx_data) self.serial.disconnect() self.serial.connect("COM8", 115200) self.serial.start() def on_rx_data(self, c): print(c) self.protocol.decode(c) def on_new_payload(self, payload): print("decoded :", payload)
c.append(int('00', 16)) c.append(int('7f', 16)) #VALUE c.append(int('05', 16)) c.append(int('f7', 16)) c.append(int('E4', 16)) c.append(int('7D', 16)) return c def on_new_payload(rxpayload): print("TX :", rxpayload) if __name__ == '__main__': # Create protocol and give callback function protocol = Protocol(on_new_payload) # Test to decode for c in build_rx_value(): protocol.decode(c) # Test to encode tx = protocol.encode(build_tx_value()) build_rx_value() print("TX :", tx) print("Done.")
#DATAID c.append(int('00',16)) c.append(int('7f',16)) #VALUE c.append(int('05',16)) c.append(int('f7',16)) c.append(int('E4',16)) c.append(int('7D',16)) return c def on_new_payload(rxpayload): print("TX :",rxpayload) if __name__ == '__main__': # Create protocol and give callback function protocol = Protocol(on_new_payload) # Test to decode for c in build_rx_value(): protocol.decode(c) # Test to encode tx = protocol.encode(build_tx_value()) build_rx_value() print("TX :",tx) print("Done.")