import serial def main(serial_port): comm = serial.Serial(serial_port, 115200) # comm.write(b"Hello World!") # for _ in range(32): while True: byte = comm.read(2) print(f'{byte[0]:0>8b}' + f'{byte[1]:0>8b}') byte = comm.read(1) print(f'{byte[0]:0>8b}') # cached_byte = None # while True: # byte = comm.read(1) # if byte != cached_byte: # cached_byte = byte # print(f'{byte[0]:0>8b}') if __name__ == "__main__": import argparse parser = argparse.ArgumentParser() parser.add_argument("platform") args = parser.parse_args() port_dict = { "kasli": "/dev/ttyUSB3", "efc": "/dev/ttyACM1", } main(port_dict[args.platform])