~shiny/gbcap

ref: 1da1303482353adde97934cacee4f402f4e1c118 gbcap/com.py -rwxr-xr-x 471 bytes
1da13034Thomas Spurden Add uart test helper 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)