From a49a8f00f6c729dfd833815d10092f1a476c2a06 Mon Sep 17 00:00:00 2001 From: Florian Sylvestre Date: Mon, 13 May 2024 16:31:15 +0200 Subject: [PATCH] adi/ad7944: use the sampling_frequency attribute provided by iio:device Signed-off-by: Florian Sylvestre --- adi/ad7944.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/adi/ad7944.py b/adi/ad7944.py index d6b6e2526..8310f844e 100644 --- a/adi/ad7944.py +++ b/adi/ad7944.py @@ -29,13 +29,7 @@ def __init__(self, uri="ip:analog.local", device_name="ad7944"): if device_name not in self._compatible_parts: raise Exception(f"Not a compatible device: {device_name}") - # TODO: if/when pyadi-iio and libiio get refactored, this could - # be done more gracefully. The device object should have a - # trigger property that is directly accessible for the sampling - # frequency, but this is broken in libiio 0.25. - trigger_name = "trigger0" self._rxadc = self._ctrl = self._ctx.find_device(device_name) - self._trigger = self._ctx.find_device(trigger_name) if not self._ctrl: raise Exception(f"Error in selecting matching device {device_name}") @@ -49,12 +43,12 @@ def __init__(self, uri="ip:analog.local", device_name="ad7944"): @property def sampling_frequency(self): """Get sampling frequency.""" - return self._trigger.frequency + return self._get_iio_dev_attr("sampling_frequency") @sampling_frequency.setter def sampling_frequency(self, rate): """Set sampling frequency.""" - self._trigger.frequency = rate + self._set_iio_dev_attr("sampling_frequency", rate) class ad7985(ad7944):