pothosware / SoapySDR

Vendor and platform neutral SDR support library.
https://github.com/pothosware/SoapySDR/wiki
Boost Software License 1.0
1.09k stars 176 forks source link

Unable to call getNativeStreamFormat in Python #399

Closed jrlrddn closed 1 year ago

jrlrddn commented 1 year ago

The following is the message seen on Ubuntu 22.04, with Soapy 0.8 installed via apt.

>>> import SoapySDR
>>> sdr = SoapySDR.Device(SoapySDR.Device.enumerate()[0])
>>> fullScale = 0.0
>>> sdr.getNativeStreamFormat(SoapySDR.SOAPY_SDR_RX, 0, fullScale)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/SoapySDR.py", line 1514, in getNativeStreamFormat
    return _SoapySDR.Device_getNativeStreamFormat(self, direction, channel, fullScale)
TypeError: in method 'Device_getNativeStreamFormat', argument 4 of type 'double &'

I have tried numerous other approaches to appease the 4th argument, but to no avail.

The same issue was verified on Fedora 37 with Soapy built from source (commit 9c4fa32)

I have personally worked around the issue with the following changes.

diff --git a/include/SoapySDR/Device.hpp b/include/SoapySDR/Device.hpp
index 5f15485..60f3571 100644
--- a/include/SoapySDR/Device.hpp
+++ b/include/SoapySDR/Device.hpp
@@ -207,6 +207,19 @@ public:
      */
     virtual std::string getNativeStreamFormat(const int direction, const size_t channel, double &fullScale) const;

+    inline std::string getNativeStreamFormat(const int direction, const size_t channel) const
+    {
+        double fullScale = 0.0;
+        return getNativeStreamFormat(direction, channel, fullScale);
+    }
+
+    inline double getNativeStreamScale(const int direction, const size_t channel) const
+    {
+        double fullScale = 0.0;
+        getNativeStreamFormat(direction, channel, fullScale);
+        return fullScale;
+    }
+
     /*!
      * Query the argument info description for stream args.
      * \param direction the channel direction RX or TX
ncorgan commented 1 year ago

Closed via https://github.com/pothosware/SoapySDR/pull/407, thanks for reporting!