import serial def main(): comm = serial.Serial("/dev/ttyUSB3", 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__": main()