aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2022-04-15 10:37:47 -0700
committerAaron Rossetto <aaron.rossetto@ni.com>2022-04-15 14:29:01 -0700
commit13541623fa84e88004cf14b388e2e963885462eb (patch)
treeb63028647d1dc370f220c28f3513d28b27733691 /tools
parentc1f1f32d0b66d2f7bc9b59924792f2d8eb773710 (diff)
downloaduhd-13541623fa84e88004cf14b388e2e963885462eb.tar.gz
uhd-13541623fa84e88004cf14b388e2e963885462eb.tar.bz2
uhd-13541623fa84e88004cf14b388e2e963885462eb.zip
tools: Fixes to uhd_phase_alignment.py
A few minor fixes so the script works for N210: - Set source on master mboard to "external" if "mimo" ref or pps is specified. - Add support for comma-separated lists for ref and pps arguments. - Fix bug where not supplying the lo_source argument would cause the script to fail. Signed-off-by: michael-west <michael.west@ettus.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/gr-usrptest/apps/uhd_phase_alignment.py73
1 files changed, 49 insertions, 24 deletions
diff --git a/tools/gr-usrptest/apps/uhd_phase_alignment.py b/tools/gr-usrptest/apps/uhd_phase_alignment.py
index edf12a231..a4411042d 100755
--- a/tools/gr-usrptest/apps/uhd_phase_alignment.py
+++ b/tools/gr-usrptest/apps/uhd_phase_alignment.py
@@ -85,7 +85,7 @@ def parse_args():
help="specify a minimum frequency")
parser.add_argument("--stop-freq", type=float, required=True,
help="specify a maximum frequency")
- parser.add_argument("--freq-bands", type=float, required=True,
+ parser.add_argument("--freq-bands", type=int, required=True,
help="specify the number of frequency bands to test")
parser.add_argument("--start-power", type=float, default=-30,
help="specify a starting output power for the siggen (dBm)")
@@ -175,14 +175,25 @@ class LogFormatter(logging.Formatter):
def setup_ref(usrp, ref, num_mboards):
"""Setup the reference clock"""
- if ref == "mimo":
- if num_mboards != 2:
- logger.error("ref = \"mimo\" implies 2 motherboards; "
- "your system has %d boards", num_mboards)
- return False
- usrp.set_clock_source("mimo", 1)
+ sources = [x.strip() for x in ref.split(",")]
+ if len(sources) == 1:
+ if ref == "mimo":
+ # mimo is a special case requiring the master to be external and
+ # the slave to be mimo
+ if num_mboards != 2:
+ logger.error("ref = \"mimo\" implies 2 motherboards; "
+ "your system has %d boards", num_mboards)
+ return False
+ usrp.set_clock_source("external", 0)
+ usrp.set_clock_source("mimo", 1)
+ else:
+ usrp.set_clock_source(ref)
else:
- usrp.set_clock_source(ref)
+ if num_mboards != len(sources):
+ logger.error("number of clock sources does not match number of devices")
+ return False
+ for mboard in range(num_mboards):
+ usrp.set_clock_source(sources[mboard], mboard)
# Lock onto clock signals for all mboards
if ref != "internal":
@@ -203,15 +214,27 @@ def setup_ref(usrp, ref, num_mboards):
def setup_pps(usrp, pps, num_mboards):
"""Setup the PPS source"""
- if pps == "mimo":
- if num_mboards != 2:
- logger.error("ref = \"mimo\" implies 2 motherboards; "
- "your system has %d boards", num_mboards)
- return False
- # make mboard 1 a slave over the MIMO Cable
- usrp.set_time_source("mimo", 1)
+ sources = [x.strip() for x in pps.split(",")]
+ if len(sources) == 1:
+ # Single argument means use the same source for all mboards
+ if pps == "mimo":
+ # mimo is a special case requiring the master to be external and
+ # the slave to be mimo
+ if num_mboards != 2:
+ logger.error("ref = \"mimo\" implies 2 motherboards; "
+ "your system has %d boards", num_mboards)
+ return False
+ usrp.set_time_source("external", 0)
+ usrp.set_time_source("mimo", 1)
+ else:
+ usrp.set_time_source(pps)
else:
- usrp.set_time_source(pps)
+ # Multiple arguments means different sources for each mboards
+ if len(sources) != num_mboards:
+ logger.error("number of clock sources does not match number of devices")
+ return False
+ for mboard in range(num_mboards):
+ usrp.set_time_source(sources[mboard], mboard)
return True
@@ -329,11 +352,13 @@ def tune_usrp(usrp, freq, channels, lo_source, delay=CMD_DELAY):
Then all channels are synchronously tuned."""
treq = uhd.types.TuneRequest(freq)
- lo_source_channel = -1
- for chan, lo in zip(channels, lo_source):
- if lo == "internal":
- lo_source_channel = chan
- if lo_source_channel != -1:
+ lo_source_channel = None
+ if lo_source != None:
+ for chan, lo in zip(channels, lo_source):
+ if lo == "internal":
+ lo_source_channel = chan
+ usrp.set_command_time(generate_time_spec(usrp, time_delta=delay))
+ if lo_source_channel != None:
treq.dsp_freq = (usrp.set_rx_freq(uhd.types.TuneRequest(freq), lo_source_channel)).actual_dsp_freq
treq.target_freq = freq
treq.rf_freq = freq
@@ -343,9 +368,9 @@ def tune_usrp(usrp, freq, channels, lo_source, delay=CMD_DELAY):
if lo_source == "internal":
continue
usrp.set_rx_freq(treq, chan)
- usrp.set_command_time(generate_time_spec(usrp, time_delta=delay))
- for chan in channels:
- usrp.set_rx_freq(treq, chan)
+ else:
+ for chan in channels:
+ usrp.set_rx_freq(treq, chan)
usrp.clear_command_time()
time.sleep(delay)