diff --git a/src/ria_toolkit_oss/sdr/pluto.py b/src/ria_toolkit_oss/sdr/pluto.py index 449505e..e95ecdd 100644 --- a/src/ria_toolkit_oss/sdr/pluto.py +++ b/src/ria_toolkit_oss/sdr/pluto.py @@ -17,7 +17,7 @@ class Pluto(SDR): """ Initialize a Pluto SDR device object and connect to the SDR hardware. - This software supports the ADALAM Pluto SDR created by Analog Devices. + This software supports the ADALM Pluto SDR created by Analog Devices. :param identifier: The value of the parameter that identifies the device. :type identifier: str = "192.168.3.1", "pluto.local", etc @@ -34,8 +34,24 @@ class Pluto(SDR): else: uri = f"ip:{identifier}" - self.radio = adi.ad9361(uri) - print(f"Successfully found Pluto radio with identifier [{identifier}].") + # Detect MIMO capability by checking IIO channels (one-time, during init) + # Rev B: 2 channels (voltage0, voltage1) - single RX/TX only + # Rev C/D: 4 channels (voltage0-3) - dual RX/TX capable + test_radio = adi.ad9361(uri) + ctx = test_radio.ctx + dev = ctx.find_device("cf-ad9361-lpc") + + if dev and len(dev.channels) >= 4: + # MIMO-capable hardware (Rev C/D) + self.radio = test_radio + self._mimo_capable = True + print(f"Successfully found MIMO-capable Pluto (Rev C/D) with identifier [{identifier}].") + else: + # Non-MIMO hardware (Rev B) - use standard Pluto driver + self.radio = adi.Pluto(uri) + self._mimo_capable = False + print(f"Successfully found Pluto (Rev B) with identifier [{identifier}].") + except Exception as e: print(f"Failed to find Pluto radio with identifier [{identifier}].") raise e @@ -74,6 +90,11 @@ class Pluto(SDR): self.radio.rx_enabled_channels = [0] print(f"Pluto channel(s) = {self.radio.rx_enabled_channels}") elif channel == 1: + if not self._mimo_capable: + raise ValueError( + "Dual RX channel requested (channel=1) but hardware is not MIMO-capable. " + "Dual RX/TX requires Pluto Rev C/D. Detected hardware: Rev B (single channel only)." + ) self.radio.rx_enabled_channels = [0, 1] print(f"Pluto channel(s) = {self.radio.rx_enabled_channels}") else: @@ -142,6 +163,11 @@ class Pluto(SDR): print(f"Pluto center frequency = {self.radio.tx_lo}") if channel == 1: + if not self._mimo_capable: + raise ValueError( + "Dual TX channel requested (channel=1) but hardware is not MIMO-capable. " + "Dual RX/TX requires Pluto Rev C/D. Detected hardware: Rev B (single channel only)." + ) self.radio.tx_enabled_channels = [0, 1] print(f"Pluto channel(s) = {self.radio.tx_enabled_channels}") elif channel == 0: