util/bridge: print command names

This commit is contained in:
Jan Hamal Dvořák 2024-06-06 22:04:47 +02:00
parent 4ecefa1e5b
commit edfe86793d

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python
import binascii
import struct
from socket import (AF_INET, MSG_DONTWAIT, SO_REUSEADDR, SO_SNDBUF,
SOCK_STREAM, SOL_SOCKET, socket)
@ -8,6 +7,31 @@ from socket import (AF_INET, MSG_DONTWAIT, SO_REUSEADDR, SO_SNDBUF,
import click
import serial
COMMAND_NAMES = [
"reset",
"tune_freq",
"sample_rate",
"manual_gain",
"gain",
"ppm_offset",
"if_gain",
"test_mode",
"agc",
"direct_sampling",
"offset_tuning",
"11",
"12",
"gain_index",
"bias_tee",
]
def describe(cmd: int, arg: int):
try:
print("->", COMMAND_NAMES[cmd], arg)
except IndexError:
print("->", cmd, arg)
@click.command()
@click.option("-f", "--frequency", default=88200000, help="Frequency to tune to")
@ -43,7 +67,7 @@ def bridge(frequency):
while len(cmd) >= 5:
fp.write(cmd[:5])
info = struct.unpack(">BL", cmd[:5])
print("->", hex(info[0]), info[1])
describe(*info)
cmd = cmd[5:]
data = fp.read(64)