~shiny/gbcap

1da1303482353adde97934cacee4f402f4e1c118 — Thomas Spurden 3 months ago b91e73a
Add uart test helper
1 files changed, 18 insertions(+), 0 deletions(-)

A com.py
A com.py => com.py +18 -0
@@ 0,0 1,18 @@
#!/usr/bin/env python3
import sys
import serial
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--baud', '-b', type=int, default=115200, help='Serial baud rate')
parser.add_argument('port', help='Serial port device')
parser.add_argument('data', nargs='+')

args = parser.parse_args()

with serial.Serial(args.port, args.baud) as p:
    for d in args.data:
        p.write(d.encode('ascii'))
    while True:
        d = p.read(1)
        print(d)