aboutsummaryrefslogtreecommitdiffstats
path: root/dpd/src/Adapt.py
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-09-04 20:04:52 +0200
committerandreas128 <Andreas>2017-09-04 20:04:52 +0200
commit85ab46bfa7f28530cdd30f2bf3129479e735de7f (patch)
treea840c4516868a9b77024326d0fe4f412f37b6abe /dpd/src/Adapt.py
parent719238f0adc19fb3de3b4fd2695b6bb30d4c9dd5 (diff)
downloaddabmod-85ab46bfa7f28530cdd30f2bf3129479e735de7f.tar.gz
dabmod-85ab46bfa7f28530cdd30f2bf3129479e735de7f.tar.bz2
dabmod-85ab46bfa7f28530cdd30f2bf3129479e735de7f.zip
Add get/set for digital gain
Diffstat (limited to 'dpd/src/Adapt.py')
-rw-r--r--dpd/src/Adapt.py23
1 files changed, 19 insertions, 4 deletions
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,