diff options
Diffstat (limited to 'dpd/src/Adapt.py')
-rw-r--r-- | dpd/src/Adapt.py | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/dpd/src/Adapt.py b/dpd/src/Adapt.py index 2fb596f..b4042d6 100644 --- a/dpd/src/Adapt.py +++ b/dpd/src/Adapt.py @@ -24,7 +24,7 @@ class Adapt: """ def __init__(self, port, coef_path): - logging.info("Instantiate Adapt object") + logging.debug("Instantiate Adapt object") self.port = port self.coef_path = coef_path self.host = "localhost" @@ -60,7 +60,7 @@ class Adapt: The message string that will be sent to the receiver. """ sock = self._connect() - logging.info("Send message: %s" % message) + logging.debug("Send message: %s" % message) msg_parts = message.split(" ") for i, part in enumerate(msg_parts): if i == len(msg_parts) - 1: @@ -71,7 +71,7 @@ class Adapt: sock.send(part.encode(), flags=f) data = [el.decode() for el in sock.recv_multipart()] - logging.info("Received message: %s" % message) + logging.debug("Received message: %s" % message) return data def set_txgain(self, gain): @@ -85,12 +85,12 @@ class Adapt: # TODO this is specific to the B200 if gain < 0 or gain > 89: raise ValueError("Gain has to be in [0,89]") - return self.send_receive("set uhd txgain %d" % gain) + return self.send_receive("set uhd txgain %.4f" % float(gain)) def get_txgain(self): """Get the txgain value in dB for the ODR-DabMod.""" # TODO handle failure - return self.send_receive("get uhd txgain") + return float(self.send_receive("get uhd txgain")[0]) def set_rxgain(self, gain): """Set a new rxgain for the ODR-DabMod. @@ -103,12 +103,28 @@ class Adapt: # TODO this is specific to the B200 if gain < 0 or gain > 89: raise ValueError("Gain has to be in [0,89]") - return self.send_receive("set uhd rxgain %d" % gain) + return self.send_receive("set uhd rxgain %.4f" % float(gain)) def get_rxgain(self): """Get the rxgain value in dB for the ODR-DabMod.""" # TODO handle failure - return self.send_receive("get uhd rxgain") + return float(self.send_receive("get uhd rxgain")[0]) + + def set_digital_gain(self, gain): + """Set a new rxgain for the ODR-DabMod. + + Parameters + ---------- + gain : int + new RX gain, in the same format as ODR-DabMod's config file + """ + msg = "set gain digital %.5f" % gain + return self.send_receive(msg) + + def get_digital_gain(self): + """Get the rxgain value in dB for the ODR-DabMod.""" + # TODO handle failure + return float(self.send_receive("get gain digital")[0]) def _read_coef_file(self, path): """Load the coefficients from the file in the format given in the README, |