util/bridge: print command names
This commit is contained in:
parent
4ecefa1e5b
commit
edfe86793d
1 changed files with 26 additions and 2 deletions
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import binascii
|
|
||||||
import struct
|
import struct
|
||||||
from socket import (AF_INET, MSG_DONTWAIT, SO_REUSEADDR, SO_SNDBUF,
|
from socket import (AF_INET, MSG_DONTWAIT, SO_REUSEADDR, SO_SNDBUF,
|
||||||
SOCK_STREAM, SOL_SOCKET, socket)
|
SOCK_STREAM, SOL_SOCKET, socket)
|
||||||
|
@ -8,6 +7,31 @@ from socket import (AF_INET, MSG_DONTWAIT, SO_REUSEADDR, SO_SNDBUF,
|
||||||
import click
|
import click
|
||||||
import serial
|
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.command()
|
||||||
@click.option("-f", "--frequency", default=88200000, help="Frequency to tune to")
|
@click.option("-f", "--frequency", default=88200000, help="Frequency to tune to")
|
||||||
|
@ -43,7 +67,7 @@ def bridge(frequency):
|
||||||
while len(cmd) >= 5:
|
while len(cmd) >= 5:
|
||||||
fp.write(cmd[:5])
|
fp.write(cmd[:5])
|
||||||
info = struct.unpack(">BL", cmd[:5])
|
info = struct.unpack(">BL", cmd[:5])
|
||||||
print("->", hex(info[0]), info[1])
|
describe(*info)
|
||||||
cmd = cmd[5:]
|
cmd = cmd[5:]
|
||||||
|
|
||||||
data = fp.read(64)
|
data = fp.read(64)
|
||||||
|
|
Loading…
Reference in a new issue