serdes-transceiver/comm.py

23 lines
506 B
Python
Raw Normal View History

2023-04-23 11:42:18 +08:00
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()