aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2020-06-01 13:37:08 -0700
committerAaron Rossetto <aaron.rossetto@ni.com>2020-06-03 15:15:14 -0500
commite62c93fe15feb807acb0772080d77e185f70494f (patch)
tree977e3e83482ff52f7788341ed4b7b2a15f25f31a
parentae426043df93c4c0255ae05419953645214ff198 (diff)
downloaduhd-e62c93fe15feb807acb0772080d77e185f70494f.tar.gz
uhd-e62c93fe15feb807acb0772080d77e185f70494f.tar.bz2
uhd-e62c93fe15feb807acb0772080d77e185f70494f.zip
python: cal: Improve meas_device.py
- Remove some PyLint issues by aligning the argument list for SignalGeneratorBase.enable() - Improve an assertion: Since a valid power level is 0 dBm, we need to explicitly check max power against None, not 0 - Improve the error message for when no device is found ("signal generator" instead of "RX measurement device", since the latter is confusing/ambiguous)
-rw-r--r--host/python/uhd/usrp/cal/meas_device.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/host/python/uhd/usrp/cal/meas_device.py b/host/python/uhd/usrp/cal/meas_device.py
index 22fe78c11..d6b40eb84 100644
--- a/host/python/uhd/usrp/cal/meas_device.py
+++ b/host/python/uhd/usrp/cal/meas_device.py
@@ -66,7 +66,7 @@ class SignalGeneratorBase:
# Make sure to set this before doing RX cal
self.max_output_power = None
- def enable(self, enb=True):
+ def enable(self, enable=True):
"""
Turn on the power generator. By default, it should be off, and only
produce a signal when this was called with an argument value of 'True'.
@@ -82,7 +82,7 @@ class SignalGeneratorBase:
This will coerce to the next possible power available and return the
coerced value.
"""
- assert self.max_output_power
+ assert self.max_output_power is not None
if power_dbm > self.max_output_power:
print("[SigGen] WARNING! Trying to set power beyond safe levels. "
"Capping output power at {} dBm.".format(self.max_output_power))
@@ -288,11 +288,11 @@ class USRPPowerGenerator(SignalGeneratorBase):
self._tone_gen = ToneGenerator(self._rate, self._tone_freq, self._amplitude)
self._tone_gen.set_streamer(self._streamer)
- def enable(self, enb=True):
+ def enable(self, enable=True):
"""
Turn the tone generator on or off.
"""
- if enb:
+ if enable:
print("[SigGen] Starting tone generator.")
self._tone_gen.start()
else:
@@ -349,5 +349,5 @@ def get_meas_device(direction, dev_key, options):
return obj(opt_dict)
except TypeError:
continue
- raise RuntimeError("No {} measurement device found for key: {}".format(
- direction.upper(), dev_key))
+ raise RuntimeError("No {} found for key: {}".format(
+ "signal generator" if direction == "rx" else "power meter", dev_key))