From e62c93fe15feb807acb0772080d77e185f70494f Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Mon, 1 Jun 2020 13:37:08 -0700 Subject: 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) --- host/python/uhd/usrp/cal/meas_device.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'host/python') 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)) -- cgit v1.2.3