From 85ab46bfa7f28530cdd30f2bf3129479e735de7f Mon Sep 17 00:00:00 2001 From: andreas128 Date: Mon, 4 Sep 2017 20:04:52 +0200 Subject: Add get/set for digital gain --- dpd/src/Adapt.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'dpd/src/Adapt.py') diff --git a/dpd/src/Adapt.py b/dpd/src/Adapt.py index 7b33851..78eaa9e 100644 --- a/dpd/src/Adapt.py +++ b/dpd/src/Adapt.py @@ -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): @@ -90,7 +90,7 @@ class Adapt: 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 int(self.send_receive("get uhd txgain")[0]) def set_rxgain(self, gain): """Set a new rxgain for the ODR-DabMod. @@ -108,7 +108,22 @@ class Adapt: 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 int(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 + """ + return self.send_receive("set gain digital %.5f" % gain) + + 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, -- cgit v1.2.3