bridge: make device path a parameter

This commit is contained in:
Jan Hamal Dvořák 2024-06-25 18:09:56 +02:00
parent 46aee7f5d2
commit 7f98ab98f0

View file

@ -35,7 +35,8 @@ def describe(cmd: int, arg: int):
@click.command()
@click.option("-f", "--frequency", default=88200000, help="Frequency to tune to")
def bridge(frequency):
@click.option("-d", "--device", default="/dev/ttyACM0", help="Serial port device")
def bridge(frequency, device):
sock = socket(AF_INET, SOCK_STREAM)
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
sock.setsockopt(SOL_SOCKET, SO_SNDBUF, 1024 * 100)
@ -48,7 +49,7 @@ def bridge(frequency):
peer, addr = sock.accept()
print("Client connected:", addr)
with serial.Serial("/dev/ttyACM0", baudrate=10_000_000, timeout=0.1) as fp:
with serial.Serial(device, baudrate=10_000_000, timeout=0.1) as fp:
print(f"Starting RX @ {frequency}")
# Remove any leftovers.