diff --git a/adi/ad7124.py b/adi/ad7124.py index 9eda4a0c0..057de82c4 100644 --- a/adi/ad7124.py +++ b/adi/ad7124.py @@ -36,32 +36,16 @@ def __init__(self, uri="", device_index=0): else: index += 1 - # dynamically get channels and sorting them after the index of the first voltage channel - self._ctrl.channels.sort(key=lambda x: int(x.id[7 : x.id.find("-")])) + self._rx_channel_names = [chan.name for chan in self._ctrl.channels] + if "-" in self._rx_channel_names[0]: + self._rx_channel_names.sort(key=lambda x: int(x[7:].split("-")[0])) + else: + self._rx_channel_names.sort(key=lambda x: int(x[7:])) - for ch in self._ctrl.channels: - name = ch._id - self._rx_channel_names.append(name) + for name in self._rx_channel_names: self.channel.append(self._channel(self._ctrl, name)) rx.__init__(self) - def rx(self): - sig = super().rx() - - if ( - self._rx_unbuffered_data - or self._complex_data - or self.rx_output_type == "raw" - ): - return sig - else: - mv_sig = [] - - for signal in sig: - mv_sig.append(signal / 1000) - - return mv_sig - @property def sample_rate(self): """Sets sampling frequency of the AD7124""" diff --git a/test/emu/devices/ad7124-8.xml b/test/emu/devices/ad7124-8.xml new file mode 100755 index 000000000..45c4ef60a --- /dev/null +++ b/test/emu/devices/ad7124-8.xml @@ -0,0 +1 @@ +]> \ No newline at end of file diff --git a/test/emu/hardware_map.yml b/test/emu/hardware_map.yml index a49b5d79c..e19b96cfc 100644 --- a/test/emu/hardware_map.yml +++ b/test/emu/hardware_map.yml @@ -442,3 +442,14 @@ adis16475: - iio:device0 - pyadi_iio_class_support: - adis16475 + +ad7124-8: + - ad7124 + - pyadi_iio_class_support: + - ad7124 + - emulate: + - filename: ad7124-8.xml + - data_devices: + - iio:device0 + - pyadi_iio_class_support: + - ad7124 \ No newline at end of file diff --git a/test/test_ad7124_8.py b/test/test_ad7124_8.py new file mode 100644 index 000000000..ade7e09f2 --- /dev/null +++ b/test/test_ad7124_8.py @@ -0,0 +1,14 @@ +import adi +import pytest + +hardware = "ad7124-8" +classname = "adi.ad7124" + + +######################################### +@pytest.mark.iio_hardware(hardware) +def test_ad7124_8_channels(iio_uri): + dev = adi.ad7124(uri=iio_uri) + + for chan_i in range(16): + assert dev.rx_channel_names[chan_i] == f"voltage{str(chan_i)}"