Commit e2bf69fe authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Check ports

parent ec2b1cf0
......@@ -7,6 +7,45 @@ import os
from make_sigmf import make_sigmf, dataformat_to_str
from datetime import datetime
def check_ports(freq, ant, subdev, raise_exception=False):
"""
Checks whether frequency matches the antenna with the default CAMRAS B210 plugging
Returns True if everything is ok
If the setup is suspicious, prints a warning and returns False, or throws if raise_exception is set to True.
"""
def print_or_raise(msg):
if raise_exception:
raise RuntimeError(msg)
else:
print(msg)
if (200e6 < freq < 800e6):
expected_ant = "TX/RX"
expected_subdevs = ("", "A:A")
elif (800e6 < freq < 1500e6):
expected_ant = "RX2"
expected_subdevs = ("", "A:A")
elif (1500e6 < freq < 2500e6):
expected_ant = "RX2"
expected_subdevs = ("A:B",)
else:
print_or_raise(f"Unexpected frequency: {freq})")
if ant == expected_ant and subdev in expected_subdevs:
return True
else:
msg = f"""
With the standard CAMRAS B210 setup, the selected frequency does not
match the specified antenna and subdev.
For the selected frequency {freq} we would expect:
ant={expected_ant} subdev="{expected_subdevs[0]}"
""".strip()
print_or_raise(msg)
if __name__ == "__main__":
parser = ArgumentParser(description="This application streams data from a single channel of a USRP device to a file; it wraps a C++ program")
parser.add_argument("--args", help="multi uhd device address args", default="")
......@@ -51,6 +90,8 @@ if __name__ == "__main__":
print("Running set_70cm_device.py B210")
subprocess.check_output(["set_70cm_device.py", "B210"])
check_ports(float(args.freq), args.ant, args.subdev, raise_exception=True)
arg_list = []
for key, value in args_dict.items():
if isinstance(value, bool):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment