serdes-transceiver/comm.py

34 lines
755 B
Python
Raw Normal View History

2023-04-23 11:42:18 +08:00
import serial
2023-04-26 05:08:33 +08:00
def main(serial_port):
comm = serial.Serial(serial_port, 115200)
2023-04-23 11:42:18 +08:00
# 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__":
2023-04-26 05:08:33 +08:00
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])