summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Morman <jmorman@peratonlabs.com>2021-10-05 17:12:41 -0400
committermormj <34754695+mormj@users.noreply.github.com>2021-10-13 12:03:15 -0400
commit973a2da868e9a2fb71308e8e7dadc523ba73b49c (patch)
tree34955176f6b12121b975274896be1225d58465f3
parent139be21c350f28adc5f95597144026e3e7baf80e (diff)
iio: de-duplicate the pluto wrappers
The fmcomms2 source/sink were wrapped with hier blocks that were used as the basis for the pluto blocks This templatizes the fmcomms2 blocks so they can be directly used, and since the pluto block is so close to the fmcomms block, just use grc as the wrapper around it fmcomms2/pluto can also now be used as sc16 or fc32 Signed-off-by: Josh Morman <jmorman@peratonlabs.com>
-rw-r--r--gr-iio/grc/iio.tree.yml5
-rw-r--r--gr-iio/grc/iio_fmcomms2_sink.block.yml27
-rw-r--r--gr-iio/grc/iio_fmcomms2_source.block.yml37
-rw-r--r--gr-iio/grc/iio_pluto_sink.block.yml15
-rw-r--r--gr-iio/grc/iio_pluto_source.block.yml21
-rw-r--r--gr-iio/include/gnuradio/iio/CMakeLists.txt2
-rw-r--r--gr-iio/include/gnuradio/iio/fmcomms2_sink.h8
-rw-r--r--gr-iio/include/gnuradio/iio/fmcomms2_sink_fc32.h63
-rw-r--r--gr-iio/include/gnuradio/iio/fmcomms2_source.h5
-rw-r--r--gr-iio/include/gnuradio/iio/fmcomms2_source_fc32.h65
-rw-r--r--gr-iio/include/gnuradio/iio/pluto_sink.h62
-rw-r--r--gr-iio/include/gnuradio/iio/pluto_source.h51
-rw-r--r--gr-iio/include/gnuradio/iio/pluto_utils.h20
-rw-r--r--gr-iio/lib/CMakeLists.txt5
-rw-r--r--gr-iio/lib/fmcomms2_sink_fc32_impl.cc91
-rw-r--r--gr-iio/lib/fmcomms2_sink_impl.cc196
-rw-r--r--gr-iio/lib/fmcomms2_sink_impl.h20
-rw-r--r--gr-iio/lib/fmcomms2_source_fc32_impl.cc96
-rw-r--r--gr-iio/lib/fmcomms2_source_impl.cc207
-rw-r--r--gr-iio/lib/fmcomms2_source_impl.h16
-rw-r--r--gr-iio/lib/pluto_sink_impl.cc69
-rw-r--r--gr-iio/lib/pluto_sink_impl.h39
-rw-r--r--gr-iio/lib/pluto_source_impl.cc118
-rw-r--r--gr-iio/lib/pluto_source_impl.h49
-rw-r--r--gr-iio/lib/pluto_utils.cc56
-rw-r--r--gr-iio/python/iio/bindings/CMakeLists.txt10
-rw-r--r--gr-iio/python/iio/bindings/docstrings/pluto_source_pydoc_template.h23
-rw-r--r--gr-iio/python/iio/bindings/docstrings/pluto_utils_pydoc_template.h (renamed from gr-iio/python/iio/bindings/docstrings/pluto_sink_pydoc_template.h)8
-rw-r--r--gr-iio/python/iio/bindings/fmcomms2_sink_f32c_python.cc75
-rw-r--r--gr-iio/python/iio/bindings/fmcomms2_sink_python.cc61
-rw-r--r--gr-iio/python/iio/bindings/fmcomms2_source_f32c_python.cc68
-rw-r--r--gr-iio/python/iio/bindings/fmcomms2_source_python.cc33
-rw-r--r--gr-iio/python/iio/bindings/fmcomms5_sink_f32c_python.cc83
-rw-r--r--gr-iio/python/iio/bindings/fmcomms5_source_f32c_python.cc96
-rw-r--r--gr-iio/python/iio/bindings/pluto_sink_python.cc51
-rw-r--r--gr-iio/python/iio/bindings/pluto_source_python.cc55
-rw-r--r--gr-iio/python/iio/bindings/pluto_utils_python.cc34
-rw-r--r--gr-iio/python/iio/bindings/python_bindings.cc18
38 files changed, 650 insertions, 1308 deletions
diff --git a/gr-iio/grc/iio.tree.yml b/gr-iio/grc/iio.tree.yml
index 7e5b34daf0..11faae92a4 100644
--- a/gr-iio/grc/iio.tree.yml
+++ b/gr-iio/grc/iio.tree.yml
@@ -7,6 +7,11 @@
- iio_attr_sink
- iio_attr_updater
- iio_dds_control
+ - 'FMComms':
+ - iio_fmcomms2_source
+ - iio_fmcomms2_sink
+ # - iio_fmcomms5_source
+ # - iio_fmcomms5_sink
- 'PlutoSDR':
- iio_pluto_source
- iio_pluto_sink
diff --git a/gr-iio/grc/iio_fmcomms2_sink.block.yml b/gr-iio/grc/iio_fmcomms2_sink.block.yml
index 9e04cc447a..97d4a16c77 100644
--- a/gr-iio/grc/iio_fmcomms2_sink.block.yml
+++ b/gr-iio/grc/iio_fmcomms2_sink.block.yml
@@ -3,6 +3,15 @@ label: FMComms2/3/4 Sink
flags: [ python, throttle ]
parameters:
+- id: type
+ label: Input Type
+ dtype: enum
+ options: [fc32, sc16]
+ option_labels: [int16, Complex float32, Complex int16]
+ option_attributes:
+ type: [fc32, sc16]
+ hide: part
+
- id: uri
label: IIO context URI
dtype: string
@@ -106,7 +115,7 @@ parameters:
inputs:
- domain: stream
- dtype: complex
+ dtype: ${type.type}
multiplicity: ${ sum([tx1_en, tx2_en]) }
asserts:
@@ -122,8 +131,18 @@ asserts:
templates:
imports: from gnuradio import iio
- make: iio.fmcomms2_sink_f32c(${uri}, ${frequency}, ${samplerate}, ${bandwidth}, ${tx1_en}, ${tx2_en}, ${buffer_size}, ${cyclic}, ${rf_port_select}, ${attenuation1}, ${attenuation2}, ${filter_source}, ${filter}, ${fpass}, ${fstop})
+ make: |
+ iio.fmcomms2_sink_${type.type}(${uri}, [tx1_en, tx2_en], ${buffer_size}, ${cyclic})
+ self.${id}.set_len_tag_key(${len_tag_key})
+ self.${id}.set_bandwidth(${bandwidth})
+ self.${id}.set_frequency(${frequency})
+ self.${id}.set_samplerate(${samplerate})
+ self.${id}.set_attenuation(0, ${attenuation1})
+ self.${id}.set_filter_params(${filter_source}, ${filter}, ${fpass}, ${fstop})
callbacks:
- - set_params(${frequency}, ${samplerate}, ${bandwidth}, ${rf_port_select}, ${attenuation1}, ${attenuation2}, ${filter_source}, ${filter}, ${fpass}, ${fstop})
-
+ - set_bandwidth(${bandwidth})
+ - set_frequency(${frequency})
+ - set_samplerate(${samplerate})
+ - set_attenuation(${attenuation1})
+ - set_filter_params(${filter_source}, ${filter}, ${fpass}, ${fstop})
file_format: 1
diff --git a/gr-iio/grc/iio_fmcomms2_source.block.yml b/gr-iio/grc/iio_fmcomms2_source.block.yml
index d30bf718da..ee318882ce 100644
--- a/gr-iio/grc/iio_fmcomms2_source.block.yml
+++ b/gr-iio/grc/iio_fmcomms2_source.block.yml
@@ -3,6 +3,15 @@ label: FMComms2/3/4 Source
flags: [ python, throttle ]
parameters:
+- id: type
+ label: Output Type
+ dtype: enum
+ options: [fc32, sc16]
+ option_labels: [int16, Complex float32, Complex int16]
+ option_attributes:
+ type: [fc32, sc16]
+ hide: part
+
- id: uri
label: IIO context URI
dtype: string
@@ -131,7 +140,7 @@ parameters:
outputs:
- domain: stream
- dtype: complex
+ dtype: ${type.type}
multiplicity: ${ sum([rx1_en, rx2_en]) }
asserts:
@@ -147,8 +156,28 @@ asserts:
templates:
imports: from gnuradio import iio
- make: iio.fmcomms2_source_f32c(${uri}, ${frequency}, ${samplerate}, ${bandwidth}, ${rx1_en}, ${rx2_en}, ${buffer_size}, ${quadrature}, ${rfdc}, ${bbdc}, ${gain1}, ${manual_gain1}, ${gain2}, ${manual_gain2}, ${rf_port_select}, ${filter_source}, ${filter}, ${fpass}, ${fstop})
+ make: |
+ iio.fmcomms2_source_${type.type}(${uri}, [rx1_en, rx2_en], ${buffer_size})
+ self.${id}.set_len_tag_key(${len_tag_key})
+ self.${id}.set_frequency(${frequency})
+ self.${id}.set_samplerate(${samplerate})
+ self.${id}.set_gain_mode(0, ${gain1})
+ self.${id}.set_gain(0, ${manual_gain1})
+ self.${id}.set_gain_mode(1, ${gain2})
+ self.${id}.set_gain(1, ${manual_gain2})
+ self.${id}.set_quadrature(${quadrature})
+ self.${id}.set_rfdc(${rfdc})
+ self.${id}.set_bbdc(${bbdc})
+ self.${id}.set_filter_params(${filter_source}, ${filter}, ${fpass}, ${fstop})
callbacks:
- - set_params(${frequency}, ${samplerate}, ${bandwidth}, ${quadrature}, ${rfdc}, ${bbdc}, ${gain1}, ${manual_gain1}, ${gain2}, ${manual_gain2}, ${rf_port_select}, ${filter_source}, ${filter}, ${fpass}, ${fstop})
-
+ - set_frequency(${frequency})
+ - set_samplerate(${samplerate})
+ - set_gain_mode(0, ${gain1})
+ - set_gain(0, ${manual_gain1})
+ - set_gain_mode(1, ${gain1})
+ - set_gain(1, ${manual_gain1})
+ - set_quadrature(${quadrature})
+ - set_rfdc(${rfdc})
+ - set_bbdc(${bbdc})
+ - set_filter_params(${filter_source}, ${filter}, ${fpass}, ${fstop})
file_format: 1
diff --git a/gr-iio/grc/iio_pluto_sink.block.yml b/gr-iio/grc/iio_pluto_sink.block.yml
index 8aea8142ca..e5ffd6f669 100644
--- a/gr-iio/grc/iio_pluto_sink.block.yml
+++ b/gr-iio/grc/iio_pluto_sink.block.yml
@@ -3,6 +3,15 @@ label: PlutoSDR Sink
flags: [ python, throttle ]
parameters:
+- id: type
+ label: Input Type
+ dtype: enum
+ options: [fc32, sc16]
+ option_labels: [Complex float32, Complex int16]
+ option_attributes:
+ type: [fc32, sc16]
+ hide: part
+
- id: uri
label: IIO context URI
dtype: string
@@ -78,7 +87,7 @@ parameters:
inputs:
- domain: stream
- dtype: complex
+ dtype: ${type.type}
asserts:
- ${ ((samplerate>=2084000) or (filter_source!="'Off'")) }
@@ -93,12 +102,12 @@ asserts:
templates:
imports: from gnuradio import iio
make: |
- iio.pluto_sink(${uri}, ${buffer_size}, ${cyclic})
+ iio.fmcomms2_sink_${type.type}(${uri} if ${uri} else iio.get_pluto_uri(), [True, True], ${buffer_size}, ${cyclic})
self.${id}.set_len_tag_key(${len_tag_key})
self.${id}.set_bandwidth(${bandwidth})
self.${id}.set_frequency(${frequency})
self.${id}.set_samplerate(${samplerate})
- self.${id}.set_attenuation(${attenuation1})
+ self.${id}.set_attenuation(0, ${attenuation1})
self.${id}.set_filter_params(${filter_source}, ${filter}, ${fpass}, ${fstop})
callbacks:
- set_bandwidth(${bandwidth})
diff --git a/gr-iio/grc/iio_pluto_source.block.yml b/gr-iio/grc/iio_pluto_source.block.yml
index da68dbd691..d90dc1028f 100644
--- a/gr-iio/grc/iio_pluto_source.block.yml
+++ b/gr-iio/grc/iio_pluto_source.block.yml
@@ -3,6 +3,15 @@ label: PlutoSDR Source
flags: [ python, throttle ]
parameters:
+- id: type
+ label: Output Type
+ dtype: enum
+ options: [fc32, sc16]
+ option_labels: [Complex float32, Complex int16]
+ option_attributes:
+ type: [fc32, sc16]
+ hide: part
+
- id: uri
label: IIO context URI
dtype: string
@@ -101,7 +110,7 @@ parameters:
outputs:
- domain: stream
- dtype: complex
+ dtype: ${type.type}
asserts:
- ${ ((samplerate>=2084000) or (filter_source!="'Off'")) }
@@ -116,12 +125,12 @@ asserts:
templates:
imports: from gnuradio import iio
make: |
- iio.pluto_source(${uri}, ${buffer_size})
+ iio.fmcomms2_source_${type.type}(${uri} if ${uri} else iio.get_pluto_uri(), [True, True], ${buffer_size})
self.${id}.set_len_tag_key(${len_tag_key})
self.${id}.set_frequency(${frequency})
self.${id}.set_samplerate(${samplerate})
- self.${id}.set_gain_mode(${gain1})
- self.${id}.set_gain(${manual_gain1})
+ self.${id}.set_gain_mode(0, ${gain1})
+ self.${id}.set_gain(0, ${manual_gain1})
self.${id}.set_quadrature(${quadrature})
self.${id}.set_rfdc(${rfdc})
self.${id}.set_bbdc(${bbdc})
@@ -129,8 +138,8 @@ templates:
callbacks:
- set_frequency(${frequency})
- set_samplerate(${samplerate})
- - set_gain_mode(${gain1})
- - set_gain(${manual_gain1})
+ - set_gain_mode(0, ${gain1})
+ - set_gain(0, ${manual_gain1})
- set_quadrature(${quadrature})
- set_rfdc(${rfdc})
- set_bbdc(${bbdc})
diff --git a/gr-iio/include/gnuradio/iio/CMakeLists.txt b/gr-iio/include/gnuradio/iio/CMakeLists.txt
index 8ad5549751..5e4d5191e7 100644
--- a/gr-iio/include/gnuradio/iio/CMakeLists.txt
+++ b/gr-iio/include/gnuradio/iio/CMakeLists.txt
@@ -22,8 +22,6 @@ install(FILES
)
if(libad9361_SUFFICIENT)
install(FILES
- pluto_sink.h
- pluto_source.h
fmcomms2_sink.h
fmcomms2_source.h
# fmcomms5_sink.h
diff --git a/gr-iio/include/gnuradio/iio/fmcomms2_sink.h b/gr-iio/include/gnuradio/iio/fmcomms2_sink.h
index af075fdcb8..9bf86cfddc 100644
--- a/gr-iio/include/gnuradio/iio/fmcomms2_sink.h
+++ b/gr-iio/include/gnuradio/iio/fmcomms2_sink.h
@@ -29,10 +29,12 @@ namespace iio {
* cards. However, it should support any AD936x based device using an IIO
* driver.
*/
+
+template <typename T>
class IIO_API fmcomms2_sink : virtual public gr::sync_block
{
public:
- typedef std::shared_ptr<fmcomms2_sink> sptr;
+ typedef std::shared_ptr<fmcomms2_sink<T>> sptr;
static sptr make(const std::string& uri,
const std::vector<bool>& ch_en,
@@ -62,6 +64,10 @@ public:
float fstop = 0.0) = 0;
};
+typedef fmcomms2_sink<int16_t> fmcomms2_sink_s;
+typedef fmcomms2_sink<std::complex<int16_t>> fmcomms2_sink_sc16;
+typedef fmcomms2_sink<gr_complex> fmcomms2_sink_fc32;
+
} // namespace iio
} // namespace gr
diff --git a/gr-iio/include/gnuradio/iio/fmcomms2_sink_fc32.h b/gr-iio/include/gnuradio/iio/fmcomms2_sink_fc32.h
deleted file mode 100644
index 21c6b0ad27..0000000000
--- a/gr-iio/include/gnuradio/iio/fmcomms2_sink_fc32.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 Analog Devices Inc.
- * Author: Paul Cercueil <paul.cercueil@analog.com>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-
-#ifndef INCLUDED_IIO_FMCOMMS2_SINK_FC32_H
-#define INCLUDED_IIO_FMCOMMS2_SINK_FC32_H
-
-#include <gnuradio/hier_block2.h>
-#include <gnuradio/iio/api.h>
-#include <gnuradio/iio/fmcomms2_sink.h>
-#include <gnuradio/sync_block.h>
-
-#include "device_sink.h"
-
-namespace gr {
-namespace iio {
-
-/*!
- * \brief Device specific sink for FMComms evaluation cards
- * \ingroup iio
- *
- * \details
- * This block is a sink specifically designed for FMComms2/3/4 evaluation
- * cards. However, it should support any AD936x based device using an IIO
- * driver.
- */
-class IIO_API fmcomms2_sink_f32c : virtual public gr::hier_block2
-{
-public:
- typedef std::shared_ptr<fmcomms2_sink_f32c> sptr;
-
- static sptr make(const std::string& uri,
- const std::vector<bool>& ch_en,
- unsigned long buffer_size,
- bool cyclic);
-
- virtual void set_len_tag_key(const std::string& len_tag_key);
- virtual void set_bandwidth(unsigned long bandwidth);
- virtual void set_frequency(unsigned long long frequency);
- virtual void set_samplerate(unsigned long samplerate);
- virtual void set_attenuation(size_t chan, double attenuation);
- virtual void set_filter_params(const std::string& filter_source,
- const std::string& filter_filename = "",
- float fpass = 0.0,
- float fstop = 0.0);
-
-private:
- fmcomms2_sink::sptr fmcomms2_block;
-
-protected:
- explicit fmcomms2_sink_f32c(bool tx1_en, bool tx2_en, fmcomms2_sink::sptr block);
-};
-
-} // namespace iio
-} // namespace gr
-
-#endif /* INCLUDED_IIO_FMCOMMS2_SINK_FC32_H */
diff --git a/gr-iio/include/gnuradio/iio/fmcomms2_source.h b/gr-iio/include/gnuradio/iio/fmcomms2_source.h
index 5ff846e473..9be4186bf1 100644
--- a/gr-iio/include/gnuradio/iio/fmcomms2_source.h
+++ b/gr-iio/include/gnuradio/iio/fmcomms2_source.h
@@ -29,6 +29,7 @@ namespace iio {
* cards. However, it should support any AD936x based device using an IIO
* driver.
*/
+template <typename T>
class IIO_API fmcomms2_source : virtual public gr::sync_block
{
public:
@@ -56,6 +57,10 @@ public:
float fstop = 0.0) = 0;
};
+typedef fmcomms2_source<int16_t> fmcomms2_source_s;
+typedef fmcomms2_source<std::complex<int16_t>> fmcomms2_source_sc16;
+typedef fmcomms2_source<gr_complex> fmcomms2_source_fc32;
+
} // namespace iio
} // namespace gr
diff --git a/gr-iio/include/gnuradio/iio/fmcomms2_source_fc32.h b/gr-iio/include/gnuradio/iio/fmcomms2_source_fc32.h
deleted file mode 100644
index 0ddebae284..0000000000
--- a/gr-iio/include/gnuradio/iio/fmcomms2_source_fc32.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 Analog Devices Inc.
- * Author: Paul Cercueil <paul.cercueil@analog.com>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-
-#ifndef INCLUDED_IIO_FMCOMMS2_SOURCE_FC32_H
-#define INCLUDED_IIO_FMCOMMS2_SOURCE_FC32_H
-
-#include <gnuradio/hier_block2.h>
-#include <gnuradio/iio/api.h>
-#include <gnuradio/iio/fmcomms2_source.h>
-#include <gnuradio/sync_block.h>
-
-#include "device_source.h"
-
-namespace gr {
-namespace iio {
-
-/*!
- * \brief Device specific source for FMComms evaluation cards
- * \ingroup iio
- *
- * \details
- * This block is a source specifically designed for FMComms2/3/4 evaluation
- * cards. However, it should support any AD936x based device using an IIO
- * driver.
- */
-class IIO_API fmcomms2_source_f32c : virtual public gr::hier_block2
-{
-public:
- typedef std::shared_ptr<fmcomms2_source_f32c> sptr;
-
- static sptr make(const std::string& uri,
- const std::vector<bool>& ch_en,
- unsigned long buffer_size);
-
- virtual void set_len_tag_key(const std::string& len_tag_key);
- virtual void set_frequency(unsigned long long frequency);
- virtual void set_samplerate(unsigned long samplerate);
- virtual void set_gain_mode(size_t chan, const std::string& mode);
- virtual void set_gain(size_t chan, double gain);
- virtual void set_quadrature(bool quadrature);
- virtual void set_rfdc(bool rfdc);
- virtual void set_bbdc(bool bbdc);
- virtual void set_filter_params(const std::string& filter_source,
- const std::string& filter_filename = "",
- float fpass = 0.0,
- float fstop = 0.0);
-
-private:
- fmcomms2_source::sptr fmcomms2_block;
-
-protected:
- explicit fmcomms2_source_f32c(bool rx1_en, bool rx2_en, fmcomms2_source::sptr block);
-};
-
-} // namespace iio
-} // namespace gr
-
-#endif /* INCLUDED_IIO_FMCOMMS2_SOURCE_FC32_H */
diff --git a/gr-iio/include/gnuradio/iio/pluto_sink.h b/gr-iio/include/gnuradio/iio/pluto_sink.h
deleted file mode 100644
index 2c9c1f9283..0000000000
--- a/gr-iio/include/gnuradio/iio/pluto_sink.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2017 Analog Devices Inc.
- * Author: Paul Cercueil <paul.cercueil@analog.com>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-
-#ifndef INCLUDED_IIO_PLUTO_SINK_H
-#define INCLUDED_IIO_PLUTO_SINK_H
-
-#include <gnuradio/hier_block2.h>
-#include <gnuradio/iio/api.h>
-
-namespace gr {
-namespace iio {
-/*!
- * \brief Sink block for the PlutoSDR
- * \ingroup iio
- *
- */
-class IIO_API pluto_sink : virtual public gr::hier_block2
-{
-public:
- typedef std::shared_ptr<pluto_sink> sptr;
-
- /*!
- * \brief Return a shared_ptr to a new instance of iio::fmcomms2_sink.
- *
- * \param uri String of the context uri
- * \param buffer_size Long of number of samples in buffer to send to device
- * \param cyclic Boolean, the first packet is repeated indefinitely when set
- */
- static sptr make(const std::string& uri, unsigned long buffer_size, bool cyclic);
-
- /*!
- * The key of the tag that indicates packet length.
- * When not empty, samples are expected as "packets" and
- * must be tagged as such, i.e. the first sample of a packet needs to be
- * tagged with the corresponding length of that packet.
- * Note, packet size MUST be equal to buffer_size / (1+interpolation),
- * otherwise a runtime_error will be thrown. This is a deliberate design
- * choice, because all other options would result in potentially unexpected
- * behavior.
- */
- virtual void set_len_tag_key(const std::string& val) = 0;
- virtual void set_frequency(unsigned long long frequency) = 0;
- virtual void set_bandwidth(unsigned long bandwidth) = 0;
- virtual void set_samplerate(unsigned long samplerate) = 0;
- virtual void set_attenuation(double attenuation) = 0;
- virtual void set_filter_params(const std::string& filter_source,
- const std::string& filter_filename = "",
- float fpass = 0.0,
- float fstop = 0.0) = 0;
-};
-
-} // namespace iio
-} // namespace gr
-
-#endif /* INCLUDED_IIO_PLUTO_SINK_H */
diff --git a/gr-iio/include/gnuradio/iio/pluto_source.h b/gr-iio/include/gnuradio/iio/pluto_source.h
deleted file mode 100644
index c46e309633..0000000000
--- a/gr-iio/include/gnuradio/iio/pluto_source.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2017 Analog Devices Inc.
- * Author: Paul Cercueil <paul.cercueil@analog.com>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-
-#ifndef INCLUDED_IIO_PLUTO_SOURCE_H
-#define INCLUDED_IIO_PLUTO_SOURCE_H
-
-#include <gnuradio/hier_block2.h>
-#include <gnuradio/iio/api.h>
-
-namespace gr {
-namespace iio {
-/*!
- * \brief Source block for the PlutoSDR
- * \ingroup iio
- *
- */
-class IIO_API pluto_source : virtual public gr::hier_block2
-{
-public:
- typedef std::shared_ptr<pluto_source> sptr;
-
- static sptr make(const std::string& uri, unsigned long buffer_size);
-
- /*!
- * \brief Key of the packet length tag. If empty no tag will be emitted
- */
- virtual void set_len_tag_key(const std::string& val) = 0;
-
- virtual void set_frequency(unsigned long long frequency) = 0;
- virtual void set_samplerate(unsigned long samplerate) = 0;
- virtual void set_gain_mode(const std::string& mode) = 0;
- virtual void set_gain(double gain) = 0;
- virtual void set_quadrature(bool quadrature) = 0;
- virtual void set_rfdc(bool rfdc) = 0;
- virtual void set_bbdc(bool bbdc) = 0;
- virtual void set_filter_params(const std::string& filter_source,
- const std::string& filter_filename = "",
- float fpass = 0.0,
- float fstop = 0.0) = 0;
-};
-} // namespace iio
-} // namespace gr
-
-#endif /* INCLUDED_IIO_PLUTO_SOURCE_H */
diff --git a/gr-iio/include/gnuradio/iio/pluto_utils.h b/gr-iio/include/gnuradio/iio/pluto_utils.h
new file mode 100644
index 0000000000..79c781c023
--- /dev/null
+++ b/gr-iio/include/gnuradio/iio/pluto_utils.h
@@ -0,0 +1,20 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2021 Josh Morman
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#ifndef INCLUDED_IIO_PLUTO_UTILS_H
+#define INCLUDED_IIO_PLUTO_UTILS_H
+
+#include <gnuradio/iio/api.h>
+#include <string>
+
+namespace gr {
+namespace iio {
+std::string IIO_API get_pluto_uri();
+}
+} // namespace gr
+#endif \ No newline at end of file
diff --git a/gr-iio/lib/CMakeLists.txt b/gr-iio/lib/CMakeLists.txt
index b3bf7e3ec7..d074e3cbe5 100644
--- a/gr-iio/lib/CMakeLists.txt
+++ b/gr-iio/lib/CMakeLists.txt
@@ -36,10 +36,7 @@ if(libad9361_SUFFICIENT)
target_sources(gnuradio-iio PRIVATE
fmcomms2_sink_impl.cc
fmcomms2_source_impl.cc
- fmcomms2_sink_fc32_impl.cc
- fmcomms2_source_fc32_impl.cc
- pluto_sink_impl.cc
- pluto_source_impl.cc
+ pluto_utils.cc
)
target_link_libraries(gnuradio-iio PUBLIC libad9361::ad9361)
target_compile_definitions(gnuradio-iio PUBLIC -DGR_IIO_LIBAD9361)
diff --git a/gr-iio/lib/fmcomms2_sink_fc32_impl.cc b/gr-iio/lib/fmcomms2_sink_fc32_impl.cc
deleted file mode 100644
index 13b470ebc8..0000000000
--- a/gr-iio/lib/fmcomms2_sink_fc32_impl.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 Analog Devices Inc.
- * Author: Paul Cercueil <paul.cercueil@analog.com>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gnuradio/blocks/complex_to_float.h>
-#include <gnuradio/blocks/float_to_short.h>
-#include <gnuradio/iio/fmcomms2_sink_fc32.h>
-#include <gnuradio/io_signature.h>
-
-using namespace gr::blocks;
-
-namespace gr {
-namespace iio {
-
-fmcomms2_sink_f32c::fmcomms2_sink_f32c(bool tx1_en,
- bool tx2_en,
- fmcomms2_sink::sptr sink_block)
- : hier_block2("fmcomms2_sink_f32c",
- io_signature::make((int)tx1_en + (int)tx2_en,
- (int)tx1_en + (int)tx2_en,
- sizeof(gr_complex)),
- io_signature::make(0, 0, 0)),
- fmcomms2_block(sink_block)
-{
- basic_block_sptr hier = shared_from_this();
- unsigned int num_streams = (int)tx1_en + (int)tx2_en;
-
- for (unsigned int i = 0; i < num_streams; i++) {
- float_to_short::sptr f2s1 = float_to_short::make(1, 32768.0);
- float_to_short::sptr f2s2 = float_to_short::make(1, 32768.0);
- complex_to_float::sptr c2f = complex_to_float::make();
-
- connect(hier, i, c2f, 0);
- connect(c2f, 0, f2s1, 0);
- connect(c2f, 1, f2s2, 0);
- connect(f2s1, 0, sink_block, i * 2);
- connect(f2s2, 0, sink_block, i * 2 + 1);
- }
-}
-
-fmcomms2_sink_f32c::sptr fmcomms2_sink_f32c::make(const std::string& uri,
- const std::vector<bool>& ch_en,
- unsigned long buffer_size,
- bool cyclic)
-{
- fmcomms2_sink::sptr block = fmcomms2_sink::make(uri, ch_en, buffer_size, cyclic);
-
- return gnuradio::get_initial_sptr(new fmcomms2_sink_f32c(
- (ch_en.size() > 0 && ch_en[0]), (ch_en.size() > 1 && ch_en[1]), block));
-}
-
-
-void fmcomms2_sink_f32c::set_len_tag_key(const std::string& len_tag_key)
-{
- fmcomms2_block->set_len_tag_key(len_tag_key);
-}
-void fmcomms2_sink_f32c::set_bandwidth(unsigned long bandwidth)
-{
- fmcomms2_block->set_bandwidth(bandwidth);
-}
-void fmcomms2_sink_f32c::set_frequency(unsigned long long frequency)
-{
- fmcomms2_block->set_frequency(frequency);
-}
-void fmcomms2_sink_f32c::set_samplerate(unsigned long samplerate)
-{
- fmcomms2_block->set_samplerate(samplerate);
-}
-void fmcomms2_sink_f32c::set_attenuation(size_t chan, double attenuation)
-{
- fmcomms2_block->set_attenuation(chan, attenuation);
-}
-void fmcomms2_sink_f32c::set_filter_params(const std::string& filter_source,
- const std::string& filter_filename,
- float fpass,
- float fstop)
-{
- fmcomms2_block->set_filter_params(filter_source, filter_filename, fpass, fstop);
-}
-
-} /* namespace iio */
-} /* namespace gr */
diff --git a/gr-iio/lib/fmcomms2_sink_impl.cc b/gr-iio/lib/fmcomms2_sink_impl.cc
index 417816d9e4..f158ab6d9b 100644
--- a/gr-iio/lib/fmcomms2_sink_impl.cc
+++ b/gr-iio/lib/fmcomms2_sink_impl.cc
@@ -28,19 +28,21 @@
namespace gr {
namespace iio {
-fmcomms2_sink::sptr fmcomms2_sink::make(const std::string& uri,
- const std::vector<bool>& ch_en,
- unsigned long buffer_size,
- bool cyclic)
+template <typename T>
+typename fmcomms2_sink<T>::sptr fmcomms2_sink<T>::make(const std::string& uri,
+ const std::vector<bool>& ch_en,
+ unsigned long buffer_size,
+ bool cyclic)
{
- return gnuradio::get_initial_sptr(new fmcomms2_sink_impl(
+ return gnuradio::get_initial_sptr(new fmcomms2_sink_impl<T>(
device_source_impl::get_context(uri), ch_en, buffer_size, cyclic));
}
-std::vector<std::string> fmcomms2_sink_impl::get_channels_vector(bool ch1_en,
- bool ch2_en,
- bool ch3_en,
- bool ch4_en)
+template <typename T>
+std::vector<std::string> fmcomms2_sink_impl<T>::get_channels_vector(bool ch1_en,
+ bool ch2_en,
+ bool ch3_en,
+ bool ch4_en)
{
std::vector<std::string> channels;
if (ch1_en)
@@ -54,8 +56,9 @@ std::vector<std::string> fmcomms2_sink_impl::get_channels_vector(bool ch1_en,
return channels;
}
+template <typename T>
std::vector<std::string>
-fmcomms2_sink_impl::get_channels_vector(const std::vector<bool>& ch_en)
+fmcomms2_sink_impl<T>::get_channels_vector(const std::vector<bool>& ch_en)
{
std::vector<std::string> channels;
int idx = 0;
@@ -69,13 +72,36 @@ fmcomms2_sink_impl::get_channels_vector(const std::vector<bool>& ch_en)
return channels;
}
+template <>
+fmcomms2_sink_impl<int16_t>::fmcomms2_sink_impl(iio_context* ctx,
+ const std::vector<bool>& ch_en,
+ unsigned long buffer_size,
+ bool cyclic)
+ : gr::sync_block("fmcomms2_sink",
+ gr::io_signature::make(1, -1, sizeof(int16_t)),
+ gr::io_signature::make(0, 0, 0)),
+ device_sink_impl(ctx,
+ true,
+ "cf-ad9361-dds-core-lpc",
+ get_channels_vector(ch_en),
+ "ad9361-phy",
+ std::vector<std::string>(),
+ buffer_size,
+ 0,
+ cyclic),
+ cyclic(cyclic)
+{
+ stop_thread = false;
+ underflow_thd = std::thread(&fmcomms2_sink_impl<int16_t>::check_underflow, this);
+}
-fmcomms2_sink_impl::fmcomms2_sink_impl(iio_context* ctx,
- const std::vector<bool>& ch_en,
- unsigned long buffer_size,
- bool cyclic)
+template <typename T>
+fmcomms2_sink_impl<T>::fmcomms2_sink_impl(iio_context* ctx,
+ const std::vector<bool>& ch_en,
+ unsigned long buffer_size,
+ bool cyclic)
: gr::sync_block("fmcomms2_sink",
- gr::io_signature::make(1, -1, sizeof(short)),
+ gr::io_signature::make(1, -1, sizeof(T)),
gr::io_signature::make(0, 0, 0)),
device_sink_impl(ctx,
true,
@@ -89,10 +115,21 @@ fmcomms2_sink_impl::fmcomms2_sink_impl(iio_context* ctx,
cyclic(cyclic)
{
stop_thread = false;
- underflow_thd = std::thread(&fmcomms2_sink_impl::check_underflow, this);
+ underflow_thd = std::thread(&fmcomms2_sink_impl<T>::check_underflow, this);
+
+ // Device Buffers are always presented as short from device_sink
+ auto nchans = get_channels_vector(ch_en).size();
+ d_device_bufs.resize(nchans);
+ d_device_item_ptrs.resize(nchans);
+ for (size_t i = 0; i < d_device_bufs.size(); i++) {
+ d_device_bufs[i].resize(s_initial_device_buf_size);
+ }
+ d_float_r.resize(s_initial_device_buf_size);
+ d_float_i.resize(s_initial_device_buf_size);
}
-fmcomms2_sink_impl::~fmcomms2_sink_impl()
+template <typename T>
+fmcomms2_sink_impl<T>::~fmcomms2_sink_impl()
{
std::unique_lock<std::mutex> lock(uf_mutex);
stop_thread = true;
@@ -100,12 +137,14 @@ fmcomms2_sink_impl::~fmcomms2_sink_impl()
underflow_thd.join();
}
-void fmcomms2_sink_impl::set_len_tag_key(const std::string& str)
+template <typename T>
+void fmcomms2_sink_impl<T>::set_len_tag_key(const std::string& str)
{
device_sink_impl::set_len_tag_key(str);
}
-void fmcomms2_sink_impl::check_underflow(void)
+template <typename T>
+void fmcomms2_sink_impl<T>::check_underflow(void)
{
uint32_t status;
int ret;
@@ -136,7 +175,8 @@ void fmcomms2_sink_impl::check_underflow(void)
}
}
-void fmcomms2_sink_impl::set_bandwidth(unsigned long bandwidth)
+template <typename T>
+void fmcomms2_sink_impl<T>::set_bandwidth(unsigned long bandwidth)
{
std::vector<std::string> params;
params.push_back("out_voltage_rf_bandwidth=" + std::to_string(bandwidth));
@@ -144,21 +184,26 @@ void fmcomms2_sink_impl::set_bandwidth(unsigned long bandwidth)
d_bandwidth = bandwidth;
}
-void fmcomms2_sink_impl::set_rf_port_select(const std::string& rf_port_select)
+template <typename T>
+void fmcomms2_sink_impl<T>::set_rf_port_select(const std::string& rf_port_select)
{
std::vector<std::string> params;
params.push_back("out_voltage0_rf_port_select=" + rf_port_select);
device_source_impl::set_params(this->phy, params);
d_rf_port_select = rf_port_select;
}
-void fmcomms2_sink_impl::set_frequency(unsigned long long frequency)
+
+template <typename T>
+void fmcomms2_sink_impl<T>::set_frequency(unsigned long long frequency)
{
std::vector<std::string> params;
params.push_back("out_altvoltage1_TX_LO_frequency=" + std::to_string(frequency));
device_source_impl::set_params(this->phy, params);
d_frequency = frequency;
}
-void fmcomms2_sink_impl::set_samplerate(unsigned long samplerate)
+
+template <typename T>
+void fmcomms2_sink_impl<T>::set_samplerate(unsigned long samplerate)
{
std::vector<std::string> params;
if (samplerate < MIN_RATE) {
@@ -178,7 +223,9 @@ void fmcomms2_sink_impl::set_samplerate(unsigned long samplerate)
d_samplerate = samplerate;
update_dependent_params();
}
-void fmcomms2_sink_impl::set_attenuation(size_t chan, double attenuation)
+
+template <typename T>
+void fmcomms2_sink_impl<T>::set_attenuation(size_t chan, double attenuation)
{
bool is_fmcomms4 = !iio_device_find_channel(phy, "voltage1", false);
if ((!is_fmcomms4 && chan > 0) || chan > 1) {
@@ -197,7 +244,8 @@ void fmcomms2_sink_impl::set_attenuation(size_t chan, double attenuation)
d_attenuation[chan] = attenuation;
}
-void fmcomms2_sink_impl::update_dependent_params()
+template <typename T>
+void fmcomms2_sink_impl<T>::update_dependent_params()
{
std::vector<std::string> params;
// Set rate configuration
@@ -234,10 +282,11 @@ void fmcomms2_sink_impl::update_dependent_params()
}
}
-void fmcomms2_sink_impl::set_filter_params(const std::string& filter_source,
- const std::string& filter_filename,
- float fpass,
- float fstop)
+template <typename T>
+void fmcomms2_sink_impl<T>::set_filter_params(const std::string& filter_source,
+ const std::string& filter_filename,
+ float fpass,
+ float fstop)
{
d_filter_source = filter_source;
d_filter_filename = filter_filename;
@@ -246,9 +295,87 @@ void fmcomms2_sink_impl::set_filter_params(const std::string& filter_source,
update_dependent_params();
}
-int fmcomms2_sink_impl::work(int noutput_items,
- gr_vector_const_void_star& input_items,
- gr_vector_void_star& output_items)
+template <>
+int fmcomms2_sink_impl<std::int16_t>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ // For int16_t ports, each sc16 port gets mapped into 2 device channels
+ if (2 * input_items.size() > d_device_item_ptrs.size()) {
+ d_device_item_ptrs.resize(2 * input_items.size());
+ d_device_bufs.resize(2 * input_items.size());
+ }
+
+ for (size_t i = 0; i < input_items.size(); i++) {
+ auto in = static_cast<const std::complex<int16_t>*>(input_items[i]);
+ if (noutput_items > (int)d_device_bufs[i].size()) {
+ d_device_bufs[2 * i].resize(noutput_items);
+ d_device_bufs[2 * i + 1].resize(noutput_items);
+ }
+ d_device_item_ptrs[2 * i] = static_cast<const void*>(d_device_bufs[2 * i].data());
+ d_device_item_ptrs[2 * i + 1] =
+ static_cast<const void*>(d_device_bufs[2 * i + 1].data());
+
+ // deinterleave complex to float
+ volk_16ic_deinterleave_16i_x2(d_device_bufs[2 * i].data(),
+ d_device_bufs[2 * i + 1].data(),
+ in,
+ noutput_items);
+ }
+
+ int ret = device_sink_impl::work(noutput_items, d_device_item_ptrs, output_items);
+ if (ret < 0 || !cyclic)
+ return ret;
+ else
+ return WORK_DONE;
+}
+
+template <>
+int fmcomms2_sink_impl<gr_complex>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ // For gr_complex ports, each gr_complex port gets mapped into 2 device channels
+ if (2 * input_items.size() > d_device_item_ptrs.size()) {
+ d_device_item_ptrs.resize(2 * input_items.size());
+ d_device_bufs.resize(2 * input_items.size());
+ }
+
+ for (size_t i = 0; i < input_items.size(); i++) {
+ auto in = static_cast<const gr_complex*>(input_items[i]);
+ if (noutput_items > (int)d_device_bufs[i].size()) {
+ d_device_bufs[2 * i].resize(noutput_items);
+ d_device_bufs[2 * i + 1].resize(noutput_items);
+ d_float_r.resize(noutput_items);
+ d_float_i.resize(noutput_items);
+ }
+ d_device_item_ptrs[2 * i] = static_cast<const void*>(d_device_bufs[2 * i].data());
+ d_device_item_ptrs[2 * i + 1] =
+ static_cast<const void*>(d_device_bufs[2 * i + 1].data());
+
+
+ // deinterleave complex to float
+ volk_32fc_deinterleave_32f_x2(
+ d_float_r.data(), d_float_i.data(), in, noutput_items);
+ // float to short
+ volk_32f_s32f_convert_16i(
+ d_device_bufs[2 * i].data(), d_float_r.data(), 2048.0, noutput_items);
+ volk_32f_s32f_convert_16i(
+ d_device_bufs[2 * i + 1].data(), d_float_i.data(), 2048.0, noutput_items);
+ }
+
+
+ int ret = device_sink_impl::work(noutput_items, d_device_item_ptrs, output_items);
+ if (ret < 0 || !cyclic)
+ return ret;
+ else
+ return WORK_DONE;
+}
+
+template <typename T>
+int fmcomms2_sink_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
{
int ret = device_sink_impl::work(noutput_items, input_items, output_items);
if (ret < 0 || !cyclic)
@@ -256,5 +383,10 @@ int fmcomms2_sink_impl::work(int noutput_items,
else
return WORK_DONE;
}
+
+template class fmcomms2_sink<int16_t>;
+template class fmcomms2_sink<std::complex<int16_t>>;
+template class fmcomms2_sink<gr_complex>;
+
} /* namespace iio */
} /* namespace gr */
diff --git a/gr-iio/lib/fmcomms2_sink_impl.h b/gr-iio/lib/fmcomms2_sink_impl.h
index 98aff11450..c900bdf3c8 100644
--- a/gr-iio/lib/fmcomms2_sink_impl.h
+++ b/gr-iio/lib/fmcomms2_sink_impl.h
@@ -18,10 +18,13 @@
#include <thread>
#include <vector>
+#include <volk/volk_alloc.hh>
+
namespace gr {
namespace iio {
-class fmcomms2_sink_impl : public fmcomms2_sink, public device_sink_impl
+template <class T>
+class fmcomms2_sink_impl : public fmcomms2_sink<T>, public device_sink_impl
{
private:
bool cyclic, stop_thread;
@@ -34,6 +37,17 @@ private:
std::vector<std::string> get_channels_vector(const std::vector<bool>& ch_en);
void check_underflow(void);
+ const static int s_initial_device_buf_size = 8192;
+
+ std::vector<volk::vector<short>> d_device_bufs;
+ gr_vector_const_void_star d_device_item_ptrs;
+ volk::vector<float> d_float_r;
+ volk::vector<float> d_float_i;
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+
public:
fmcomms2_sink_impl(iio_context* ctx,
const std::vector<bool>& ch_en,
@@ -42,10 +56,6 @@ public:
~fmcomms2_sink_impl();
- int work(int noutput_items,
- gr_vector_const_void_star& input_items,
- gr_vector_void_star& output_items);
-
void update_dependent_params();
virtual void set_len_tag_key(const std::string& len_tag_key);
virtual void set_bandwidth(unsigned long bandwidth);
diff --git a/gr-iio/lib/fmcomms2_source_fc32_impl.cc b/gr-iio/lib/fmcomms2_source_fc32_impl.cc
deleted file mode 100644
index 15e102b117..0000000000
--- a/gr-iio/lib/fmcomms2_source_fc32_impl.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2014 Analog Devices Inc.
- * Author: Paul Cercueil <paul.cercueil@analog.com>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gnuradio/blocks/float_to_complex.h>
-#include <gnuradio/blocks/short_to_float.h>
-#include <gnuradio/iio/fmcomms2_source_fc32.h>
-#include <gnuradio/io_signature.h>
-
-using namespace gr::blocks;
-
-namespace gr {
-namespace iio {
-
-fmcomms2_source_f32c::fmcomms2_source_f32c(bool rx1_en,
- bool rx2_en,
- fmcomms2_source::sptr src_block)
- : hier_block2("fmcomms2_f32c",
- io_signature::make(0, 0, 0),
- io_signature::make((int)rx1_en + (int)rx2_en,
- (int)rx1_en + (int)rx2_en,
- sizeof(gr_complex))),
- fmcomms2_block(src_block)
-{
- basic_block_sptr hier = shared_from_this();
- unsigned int num_streams = (int)rx1_en + (int)rx2_en;
-
- for (unsigned int i = 0; i < num_streams; i++) {
- short_to_float::sptr s2f1 = short_to_float::make(1, 2048.0);
- short_to_float::sptr s2f2 = short_to_float::make(1, 2048.0);
- float_to_complex::sptr f2c = float_to_complex::make(1);
-
- connect(src_block, i * 2, s2f1, 0);
- connect(src_block, i * 2 + 1, s2f2, 0);
- connect(s2f1, 0, f2c, 0);
- connect(s2f2, 0, f2c, 1);
- connect(f2c, 0, hier, i);
- }
-}
-
-fmcomms2_source_f32c::sptr fmcomms2_source_f32c::make(const std::string& uri,
- const std::vector<bool>& ch_en,
- unsigned long buffer_size)
-{
- fmcomms2_source::sptr block = fmcomms2_source::make(uri, ch_en, buffer_size);
-
- return gnuradio::get_initial_sptr(new fmcomms2_source_f32c(
- (ch_en.size() > 0 && ch_en[0]), (ch_en.size() > 1 && ch_en[1]), block));
-}
-
-void fmcomms2_source_f32c::set_len_tag_key(const std::string& len_tag_key)
-{
- fmcomms2_block->set_len_tag_key(len_tag_key);
-}
-void fmcomms2_source_f32c::set_frequency(unsigned long long frequency)
-{
- fmcomms2_block->set_frequency(frequency);
-}
-void fmcomms2_source_f32c::set_samplerate(unsigned long samplerate)
-{
- fmcomms2_block->set_samplerate(samplerate);
-}
-void fmcomms2_source_f32c::set_gain_mode(size_t chan, const std::string& mode)
-{
- fmcomms2_block->set_gain_mode(chan, mode);
-}
-void fmcomms2_source_f32c::set_gain(size_t chan, double gain)
-{
- fmcomms2_block->set_gain(chan, gain);
-}
-void fmcomms2_source_f32c::set_quadrature(bool quadrature)
-{
- fmcomms2_block->set_quadrature(quadrature);
-}
-void fmcomms2_source_f32c::set_rfdc(bool rfdc) { fmcomms2_block->set_rfdc(rfdc); }
-void fmcomms2_source_f32c::set_bbdc(bool bbdc) { fmcomms2_block->set_bbdc(bbdc); }
-void fmcomms2_source_f32c::set_filter_params(const std::string& filter_source,
- const std::string& filter_filename,
- float fpass,
- float fstop)
-{
- fmcomms2_block->set_filter_params(filter_source, filter_filename, fpass, fstop);
-}
-
-
-} /* namespace iio */
-} /* namespace gr */
diff --git a/gr-iio/lib/fmcomms2_source_impl.cc b/gr-iio/lib/fmcomms2_source_impl.cc
index e102e99247..e6651e49bc 100644
--- a/gr-iio/lib/fmcomms2_source_impl.cc
+++ b/gr-iio/lib/fmcomms2_source_impl.cc
@@ -19,6 +19,8 @@
#include <thread>
#include <vector>
+#include <volk/volk.h>
+
#define MIN_RATE 520333
#define DECINT_RATIO 8
#define OVERFLOW_CHECK_PERIOD_MS 1000
@@ -26,18 +28,20 @@
namespace gr {
namespace iio {
-fmcomms2_source::sptr fmcomms2_source::make(const std::string& uri,
- const std::vector<bool>& ch_en,
- unsigned long buffer_size)
+template <typename T>
+typename fmcomms2_source<T>::sptr fmcomms2_source<T>::make(const std::string& uri,
+ const std::vector<bool>& ch_en,
+ unsigned long buffer_size)
{
- return gnuradio::make_block_sptr<fmcomms2_source_impl>(
+ return gnuradio::make_block_sptr<fmcomms2_source_impl<T>>(
device_source_impl::get_context(uri), ch_en, buffer_size);
}
-std::vector<std::string> fmcomms2_source_impl::get_channels_vector(bool ch1_en,
- bool ch2_en,
- bool ch3_en,
- bool ch4_en)
+template <typename T>
+std::vector<std::string> fmcomms2_source_impl<T>::get_channels_vector(bool ch1_en,
+ bool ch2_en,
+ bool ch3_en,
+ bool ch4_en)
{
std::vector<std::string> channels;
if (ch1_en)
@@ -51,8 +55,9 @@ std::vector<std::string> fmcomms2_source_impl::get_channels_vector(bool ch1_en,
return channels;
}
+template <typename T>
std::vector<std::string>
-fmcomms2_source_impl::get_channels_vector(const std::vector<bool>& ch_en)
+fmcomms2_source_impl<T>::get_channels_vector(const std::vector<bool>& ch_en)
{
std::vector<std::string> channels;
int idx = 0;
@@ -66,13 +71,32 @@ fmcomms2_source_impl::get_channels_vector(const std::vector<bool>& ch_en)
return channels;
}
+template <>
+fmcomms2_source_impl<int16_t>::fmcomms2_source_impl(iio_context* ctx,
+ const std::vector<bool>& ch_en,
+ unsigned long buffer_size)
+ : gr::sync_block("fmcomms2_source",
+ gr::io_signature::make(0, 0, 0),
+ gr::io_signature::make(1, -1, sizeof(int16_t))),
+ device_source_impl(ctx,
+ true,
+ "cf-ad9361-lpc",
+ get_channels_vector(ch_en),
+ "ad9361-phy",
+ std::vector<std::string>(),
+ buffer_size,
+ 0)
+{
+ overflow_thd = std::thread(&fmcomms2_source_impl<int16_t>::check_overflow, this);
+}
-fmcomms2_source_impl::fmcomms2_source_impl(iio_context* ctx,
- const std::vector<bool>& ch_en,
- unsigned long buffer_size)
+template <typename T>
+fmcomms2_source_impl<T>::fmcomms2_source_impl(iio_context* ctx,
+ const std::vector<bool>& ch_en,
+ unsigned long buffer_size)
: gr::sync_block("fmcomms2_source",
gr::io_signature::make(0, 0, 0),
- gr::io_signature::make(1, -1, sizeof(short))),
+ gr::io_signature::make(1, -1, sizeof(T))),
device_source_impl(ctx,
true,
"cf-ad9361-lpc",
@@ -82,12 +106,25 @@ fmcomms2_source_impl::fmcomms2_source_impl(iio_context* ctx,
buffer_size,
0)
{
- overflow_thd = std::thread(&fmcomms2_source_impl::check_overflow, this);
+ overflow_thd = std::thread(&fmcomms2_source_impl<T>::check_overflow, this);
+
+ // Device Buffers are always presented as short from device_sink
+ d_device_bufs.resize(get_channels_vector(ch_en).size());
+ for (size_t i = 0; i < d_device_bufs.size(); i++) {
+ d_device_bufs[i].resize(s_initial_device_buf_size);
+ }
+ d_float_ivec.resize(s_initial_device_buf_size);
+ d_float_rvec.resize(s_initial_device_buf_size);
}
-fmcomms2_source_impl::~fmcomms2_source_impl() { overflow_thd.join(); }
+template <typename T>
+fmcomms2_source_impl<T>::~fmcomms2_source_impl()
+{
+ overflow_thd.join();
+}
-void fmcomms2_source_impl::check_overflow(void)
+template <typename T>
+void fmcomms2_source_impl<T>::check_overflow(void)
{
uint32_t status;
int ret;
@@ -126,7 +163,103 @@ void fmcomms2_source_impl::check_overflow(void)
}
}
-void fmcomms2_source_impl::update_dependent_params()
+
+template <>
+int fmcomms2_source_impl<std::int16_t>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ if (2 * output_items.size() > d_device_item_ptrs.size()) {
+ d_device_item_ptrs.resize(2 * output_items.size());
+ }
+
+ for (size_t i = 0; i < 2 * output_items.size(); i += 2) {
+ if (noutput_items > (int)d_device_bufs[i].size()) {
+ d_device_bufs[i].resize(noutput_items);
+ d_device_bufs[i + 1].resize(noutput_items);
+ }
+ d_device_item_ptrs[i] = static_cast<void*>(d_device_bufs[i].data());
+ d_device_item_ptrs[i + 1] = static_cast<void*>(d_device_bufs[i + 1].data());
+ }
+
+
+ // Since device_source returns shorts, we can just pass off the work
+ int ret = device_source_impl::work(noutput_items, input_items, d_device_item_ptrs);
+ if (ret <= 0) {
+ return ret;
+ }
+
+ // Do the conversion from shorts to interleaved shorts
+ for (size_t i = 0; i < output_items.size(); i += 2) {
+ auto out = static_cast<short*>(output_items[i]);
+
+ for (int j = 0; j < noutput_items; j++) {
+ out[2 * j] = d_device_bufs[i][j];
+ out[2 * j + 1] = d_device_bufs[i + 1][j];
+ }
+ }
+
+ return ret;
+}
+
+
+template <>
+int fmcomms2_source_impl<gr_complex>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ if (2 * output_items.size() > d_device_item_ptrs.size()) {
+ d_device_item_ptrs.resize(2 * output_items.size());
+ }
+ if (noutput_items > (int)d_float_rvec.size()) {
+ d_float_rvec.resize(noutput_items);
+ d_float_ivec.resize(noutput_items);
+ }
+ for (size_t i = 0; i < 2 * output_items.size(); i += 2) {
+ if (noutput_items > (int)d_device_bufs[i].size()) {
+ d_device_bufs[i].resize(noutput_items);
+ d_device_bufs[i + 1].resize(noutput_items);
+ }
+ d_device_item_ptrs[i] = static_cast<void*>(d_device_bufs[i].data());
+ d_device_item_ptrs[i + 1] = static_cast<void*>(d_device_bufs[i + 1].data());
+ }
+
+ int ret = device_source_impl::work(noutput_items, input_items, d_device_item_ptrs);
+ if (ret <= 0) {
+ return ret;
+ }
+
+ // Do the conversion from shorts to gr_complex
+ for (size_t i = 0; i < output_items.size(); i++) {
+ auto out = static_cast<gr_complex*>(output_items[i]);
+
+ // for (int n = 0; n < noutput_items; n++) {
+ // out[n] = gr_complex(float(d_device_bufs[i][n]) / 2048.0,
+ // float(d_device_bufs[i+1][n]) / 2048.0);
+ // }
+
+ volk_16i_s32f_convert_32f(
+ d_float_rvec.data(), d_device_bufs[i].data(), 2048.0, noutput_items);
+ volk_16i_s32f_convert_32f(
+ d_float_ivec.data(), d_device_bufs[i + 1].data(), 2048.0, noutput_items);
+
+ volk_32f_x2_interleave_32fc(
+ out, d_float_rvec.data(), d_float_ivec.data(), noutput_items);
+ }
+
+ return ret;
+}
+
+template <typename T>
+int fmcomms2_source_impl<T>::work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items)
+{
+ return device_source_impl::work(noutput_items, input_items, output_items);
+}
+
+template <typename T>
+void fmcomms2_source_impl<T>::update_dependent_params()
{
std::vector<std::string> params;
// Set rate configuration
@@ -162,19 +295,22 @@ void fmcomms2_source_impl::update_dependent_params()
}
}
-void fmcomms2_source_impl::set_len_tag_key(const std::string& len_tag_key)
+template <typename T>
+void fmcomms2_source_impl<T>::set_len_tag_key(const std::string& len_tag_key)
{
device_source_impl::set_len_tag_key(len_tag_key);
}
-void fmcomms2_source_impl::set_frequency(unsigned long long frequency)
+template <typename T>
+void fmcomms2_source_impl<T>::set_frequency(unsigned long long frequency)
{
std::vector<std::string> params;
params.push_back("out_altvoltage0_RX_LO_frequency=" + std::to_string(frequency));
device_source_impl::set_params(params);
}
-void fmcomms2_source_impl::set_samplerate(unsigned long samplerate)
+template <typename T>
+void fmcomms2_source_impl<T>::set_samplerate(unsigned long samplerate)
{
std::vector<std::string> params;
if (samplerate < MIN_RATE) {
@@ -195,7 +331,8 @@ void fmcomms2_source_impl::set_samplerate(unsigned long samplerate)
update_dependent_params();
}
-void fmcomms2_source_impl::set_gain_mode(size_t chan, const std::string& mode)
+template <typename T>
+void fmcomms2_source_impl<T>::set_gain_mode(size_t chan, const std::string& mode)
{
bool is_fmcomms4 = !iio_device_find_channel(phy, "voltage1", false);
if ((!is_fmcomms4 && chan > 0) || chan > 1) {
@@ -210,8 +347,8 @@ void fmcomms2_source_impl::set_gain_mode(size_t chan, const std::string& mode)
d_gain_mode[chan] = mode;
}
-
-void fmcomms2_source_impl::set_gain(size_t chan, double gain_value)
+template <typename T>
+void fmcomms2_source_impl<T>::set_gain(size_t chan, double gain_value)
{
bool is_fmcomms4 = !iio_device_find_channel(phy, "voltage1", false);
if ((!is_fmcomms4 && chan > 0) || chan > 1) {
@@ -231,21 +368,26 @@ void fmcomms2_source_impl::set_gain(size_t chan, double gain_value)
d_gain_value[chan] = gain_value;
}
-void fmcomms2_source_impl::set_quadrature(bool quadrature)
+template <typename T>
+void fmcomms2_source_impl<T>::set_quadrature(bool quadrature)
{
std::vector<std::string> params;
params.push_back("in_voltage_quadrature_tracking_en=" + std::to_string(quadrature));
device_source_impl::set_params(params);
d_quadrature = quadrature;
}
-void fmcomms2_source_impl::set_rfdc(bool rfdc)
+
+template <typename T>
+void fmcomms2_source_impl<T>::set_rfdc(bool rfdc)
{
std::vector<std::string> params;
params.push_back("in_voltage_rf_dc_offset_tracking_en=" + std::to_string(rfdc));
device_source_impl::set_params(params);
d_rfdc = rfdc;
}
-void fmcomms2_source_impl::set_bbdc(bool bbdc)
+
+template <typename T>
+void fmcomms2_source_impl<T>::set_bbdc(bool bbdc)
{
std::vector<std::string> params;
params.push_back("in_voltage_bb_dc_offset_tracking_en=" + std::to_string(bbdc));
@@ -253,10 +395,11 @@ void fmcomms2_source_impl::set_bbdc(bool bbdc)
d_bbdc = bbdc;
}
-void fmcomms2_source_impl::set_filter_params(const std::string& filter_source,
- const std::string& filter_filename,
- float fpass,
- float fstop)
+template <typename T>
+void fmcomms2_source_impl<T>::set_filter_params(const std::string& filter_source,
+ const std::string& filter_filename,
+ float fpass,
+ float fstop)
{
d_filter_source = filter_source;
d_filter_filename = filter_filename;
@@ -266,5 +409,9 @@ void fmcomms2_source_impl::set_filter_params(const std::string& filter_source,
update_dependent_params();
}
+template class fmcomms2_source<int16_t>;
+template class fmcomms2_source<std::complex<int16_t>>;
+template class fmcomms2_source<gr_complex>;
+
} /* namespace iio */
} /* namespace gr */
diff --git a/gr-iio/lib/fmcomms2_source_impl.h b/gr-iio/lib/fmcomms2_source_impl.h
index ebad428de7..1fa848eba4 100644
--- a/gr-iio/lib/fmcomms2_source_impl.h
+++ b/gr-iio/lib/fmcomms2_source_impl.h
@@ -17,10 +17,13 @@
#include <thread>
#include <vector>
+#include <volk/volk_alloc.hh>
+
namespace gr {
namespace iio {
-class fmcomms2_source_impl : public fmcomms2_source, public device_source_impl
+template <typename T>
+class fmcomms2_source_impl : public fmcomms2_source<T>, public device_source_impl
{
private:
std::vector<std::string>
@@ -29,6 +32,17 @@ private:
std::thread overflow_thd;
void check_overflow(void);
+ const static int s_initial_device_buf_size = 8192;
+ std::vector<volk::vector<short>> d_device_bufs;
+ gr_vector_void_star d_device_item_ptrs;
+ volk::vector<float> d_float_rvec;
+ volk::vector<float> d_float_ivec;
+
+ int work(int noutput_items,
+ gr_vector_const_void_star& input_items,
+ gr_vector_void_star& output_items);
+
+
public:
fmcomms2_source_impl(iio_context* ctx,
const std::vector<bool>& ch_en,
diff --git a/gr-iio/lib/pluto_sink_impl.cc b/gr-iio/lib/pluto_sink_impl.cc
deleted file mode 100644
index 562fc5ed0e..0000000000
--- a/gr-iio/lib/pluto_sink_impl.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2017 Analog Devices Inc.
- * Author: Paul Cercueil <paul.cercueil@analog.com>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-#include "pluto_sink_impl.h"
-#include "pluto_source_impl.h"
-#include <iio.h>
-
-#include <string>
-
-namespace gr {
-namespace iio {
-
-pluto_sink::sptr
-pluto_sink::make(const std::string& uri, unsigned long buffer_size, bool cyclic)
-{
- fmcomms2_sink::sptr block =
- fmcomms2_sink::make(uri.empty() ? pluto_source_impl::get_uri() : uri,
- { true, true, false, false },
- buffer_size,
- cyclic);
-
- return gnuradio::get_initial_sptr(new pluto_sink_impl(block));
-}
-
-pluto_sink_impl::pluto_sink_impl(fmcomms2_sink::sptr block)
- : hier_block2("pluto_sink",
- io_signature::make(1, 1, sizeof(gr_complex)),
- io_signature::make(0, 0, 0)),
- fmcomms2_sink_f32c(true, false, block)
-{
-}
-
-void pluto_sink_impl::set_len_tag_key(const std::string& len_tag_key)
-{
- fmcomms2_sink_f32c::set_len_tag_key(len_tag_key);
-}
-void pluto_sink_impl::set_frequency(unsigned long long frequency)
-{
- fmcomms2_sink_f32c::set_frequency(frequency);
-}
-void pluto_sink_impl::set_bandwidth(unsigned long bandwidth)
-{
- fmcomms2_sink_f32c::set_bandwidth(bandwidth);
-}
-void pluto_sink_impl::set_samplerate(unsigned long samplerate)
-{
- fmcomms2_sink_f32c::set_samplerate(samplerate);
-}
-void pluto_sink_impl::set_attenuation(double attenuation)
-{
- fmcomms2_sink_f32c::set_attenuation(0, attenuation);
-}
-void pluto_sink_impl::set_filter_params(const std::string& filter_source,
- const std::string& filter_filename,
- float fpass,
- float fstop)
-{
- fmcomms2_sink_f32c::set_filter_params(filter_source, filter_filename, fpass, fstop);
-}
-
-
-} // namespace iio
-} // namespace gr
diff --git a/gr-iio/lib/pluto_sink_impl.h b/gr-iio/lib/pluto_sink_impl.h
deleted file mode 100644
index 2331c413db..0000000000
--- a/gr-iio/lib/pluto_sink_impl.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2017 Analog Devices Inc.
- * Author: Paul Cercueil <paul.cercueil@analog.com>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-#ifndef INCLUDED_IIO_PLUTO_SINK_IMPL_H
-#define INCLUDED_IIO_PLUTO_SINK_IMPL_H
-
-#include "device_sink_impl.h"
-#include <gnuradio/iio/fmcomms2_sink_fc32.h>
-#include <gnuradio/iio/pluto_sink.h>
-
-namespace gr {
-namespace iio {
-
-class pluto_sink_impl : public pluto_sink, public fmcomms2_sink_f32c
-{
-public:
- explicit pluto_sink_impl(fmcomms2_sink::sptr block);
-
- virtual void set_len_tag_key(const std::string& len_tag_key) override;
- virtual void set_frequency(unsigned long long frequency);
- virtual void set_bandwidth(unsigned long bandwidth);
- virtual void set_samplerate(unsigned long samplerate);
- virtual void set_attenuation(double attenuation);
- virtual void set_filter_params(const std::string& filter_source,
- const std::string& filter_filename = "",
- float fpass = 0.0,
- float fstop = 0.0);
-};
-
-} // namespace iio
-} // namespace gr
-
-#endif /* INCLUDED_PLUTO_SINK_IMPL_H */
diff --git a/gr-iio/lib/pluto_source_impl.cc b/gr-iio/lib/pluto_source_impl.cc
deleted file mode 100644
index 00e81273ae..0000000000
--- a/gr-iio/lib/pluto_source_impl.cc
+++ /dev/null
@@ -1,118 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2017 Analog Devices Inc.
- * Author: Paul Cercueil <paul.cercueil@analog.com>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-#include "pluto_source_impl.h"
-#include <iio.h>
-
-#include <string>
-
-namespace gr {
-namespace iio {
-
-
-pluto_source::sptr pluto_source::make(const std::string& uri, unsigned long buffer_size)
-{
- fmcomms2_source::sptr block = fmcomms2_source::make(
- uri.empty() ? pluto_source_impl::get_uri() : uri, { true, true }, buffer_size);
-
- return gnuradio::make_block_sptr<pluto_source_impl>(block);
- // return gnuradio::get_initial_sptr(new pluto_source_impl(block));
-}
-
-std::string pluto_source_impl::get_uri()
-{
- iio_scan_context* ctx = iio_create_scan_context("usb", 0);
- if (!ctx)
- throw std::runtime_error("Unable to create scan context");
-
- iio_context_info** info;
- int ret = iio_scan_context_get_info_list(ctx, &info);
- if (ret < 0) {
- iio_scan_context_destroy(ctx);
- throw std::runtime_error("Unable to scan for Pluto devices");
- }
-
- if (ret == 0) {
- iio_context_info_list_free(info);
- iio_scan_context_destroy(ctx);
- throw std::runtime_error("No Pluto device found");
- }
-
- if (ret > 1) {
- printf("More than one Pluto found:\n");
-
- for (unsigned int i = 0; i < (size_t)ret; i++) {
- printf("\t%d: %s [%s]\n",
- i,
- iio_context_info_get_description(info[i]),
- iio_context_info_get_uri(info[i]));
- }
-
- printf("We will use the first one.\n");
- }
-
- std::string uri(iio_context_info_get_uri(info[0]));
- iio_context_info_list_free(info);
- iio_scan_context_destroy(ctx);
-
- return uri;
-}
-
-pluto_source_impl::pluto_source_impl(fmcomms2_source::sptr block)
- : hier_block2("pluto_source",
- io_signature::make(0, 0, 0),
- io_signature::make(1, 1, sizeof(gr_complex))),
- fmcomms2_source_f32c(true, false, block)
-{
-}
-
-void pluto_source_impl::set_len_tag_key(const std::string& len_tag_key)
-{
- fmcomms2_source_f32c::set_len_tag_key(len_tag_key);
-}
-void pluto_source_impl::set_frequency(unsigned long long frequency)
-{
- fmcomms2_source_f32c::set_frequency(frequency);
-}
-
-void pluto_source_impl::set_samplerate(unsigned long samplerate)
-{
- fmcomms2_source_f32c::set_samplerate(samplerate);
-}
-
-void pluto_source_impl::set_gain_mode(const std::string& mode)
-{
- fmcomms2_source_f32c::set_gain_mode(0, mode);
-}
-
-void pluto_source_impl::set_gain(double gain) { fmcomms2_source_f32c::set_gain(0, gain); }
-
-void pluto_source_impl::set_quadrature(bool quadrature)
-{
- fmcomms2_source_f32c::set_quadrature(quadrature);
-}
-void pluto_source_impl::set_rfdc(bool rfdc)
-{
- fmcomms2_source_f32c::set_quadrature(rfdc);
-}
-void pluto_source_impl::set_bbdc(bool bbdc)
-{
- fmcomms2_source_f32c::set_quadrature(bbdc);
-}
-
-void pluto_source_impl::set_filter_params(const std::string& filter_source,
- const std::string& filter_filename,
- float fpass,
- float fstop)
-{
- fmcomms2_source_f32c::set_filter_params(filter_source, filter_filename, fpass, fstop);
-};
-
-} // namespace iio
-} // namespace gr
diff --git a/gr-iio/lib/pluto_source_impl.h b/gr-iio/lib/pluto_source_impl.h
deleted file mode 100644
index 97c41b947f..0000000000
--- a/gr-iio/lib/pluto_source_impl.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2017 Analog Devices Inc.
- * Author: Paul Cercueil <paul.cercueil@analog.com>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-#ifndef INCLUDED_IIO_PLUTO_SOURCE_IMPL_H
-#define INCLUDED_IIO_PLUTO_SOURCE_IMPL_H
-
-#include <string>
-#include <vector>
-
-#include <gnuradio/iio/fmcomms2_source_fc32.h>
-#include <gnuradio/iio/pluto_source.h>
-
-#include "device_source_impl.h"
-
-namespace gr {
-namespace iio {
-
-class pluto_source_impl : public pluto_source, public fmcomms2_source_f32c
-{
-public:
- explicit pluto_source_impl(fmcomms2_source::sptr block);
-
- static std::string get_uri();
-
- virtual void set_len_tag_key(const std::string& len_tag_key) override;
- virtual void set_frequency(unsigned long long frequency);
- virtual void set_samplerate(unsigned long samplerate);
- virtual void set_gain_mode(const std::string& mode);
- virtual void set_gain(double gain);
- virtual void set_quadrature(bool quadrature);
- virtual void set_rfdc(bool rfdc);
- virtual void set_bbdc(bool bbdc);
-
- virtual void set_filter_params(const std::string& filter_source,
- const std::string& filter_filename = "",
- float fpass = 0.0,
- float fstop = 0.0);
-};
-
-} // namespace iio
-} // namespace gr
-
-#endif /* INCLUDED_IIO_PLUTO_SOURCE_IMPL_H */
diff --git a/gr-iio/lib/pluto_utils.cc b/gr-iio/lib/pluto_utils.cc
new file mode 100644
index 0000000000..2d8f2fed35
--- /dev/null
+++ b/gr-iio/lib/pluto_utils.cc
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2017 Analog Devices Inc.
+ * Author: Paul Cercueil <paul.cercueil@analog.com>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include <gnuradio/iio/pluto_utils.h>
+#include <iio.h>
+#include <stdexcept>
+
+namespace gr {
+namespace iio {
+
+std::string get_pluto_uri()
+{
+ iio_scan_context* ctx = iio_create_scan_context("usb", 0);
+ if (!ctx)
+ throw std::runtime_error("Unable to create scan context");
+
+ iio_context_info** info;
+ int ret = iio_scan_context_get_info_list(ctx, &info);
+ if (ret < 0) {
+ iio_scan_context_destroy(ctx);
+ throw std::runtime_error("Unable to scan for Pluto devices");
+ }
+
+ if (ret == 0) {
+ iio_context_info_list_free(info);
+ iio_scan_context_destroy(ctx);
+ throw std::runtime_error("No Pluto device found");
+ }
+
+ if (ret > 1) {
+ printf("More than one Pluto found:\n");
+
+ for (unsigned int i = 0; i < (size_t)ret; i++) {
+ printf("\t%d: %s [%s]\n",
+ i,
+ iio_context_info_get_description(info[i]),
+ iio_context_info_get_uri(info[i]));
+ }
+
+ printf("We will use the first one.\n");
+ }
+
+ std::string uri(iio_context_info_get_uri(info[0]));
+ iio_context_info_list_free(info);
+ iio_scan_context_destroy(ctx);
+
+ return uri;
+}
+} // namespace iio
+} // namespace gr
diff --git a/gr-iio/python/iio/bindings/CMakeLists.txt b/gr-iio/python/iio/bindings/CMakeLists.txt
index f143dadb78..a89411b6f8 100644
--- a/gr-iio/python/iio/bindings/CMakeLists.txt
+++ b/gr-iio/python/iio/bindings/CMakeLists.txt
@@ -16,16 +16,14 @@ list(APPEND iio_python_files
if(${libad9361_FOUND})
list(APPEND iio_python_files
- # fmcomms2_sink_f32c_python.cc
- # fmcomms2_sink_python.cc
- # fmcomms2_source_f32c_python.cc
- # fmcomms2_source_python.cc
+ fmcomms2_sink_python.cc
+ fmcomms2_source_python.cc
# fmcomms5_sink_f32c_python.cc
# fmcomms5_sink_python.cc
# fmcomms5_source_f32c_python.cc
# fmcomms5_source_python.cc
- pluto_sink_python.cc
- pluto_source_python.cc)
+ pluto_utils_python.cc
+ )
endif(${libad9361_FOUND})
GR_PYBIND_MAKE_CHECK_HASH(iio
diff --git a/gr-iio/python/iio/bindings/docstrings/pluto_source_pydoc_template.h b/gr-iio/python/iio/bindings/docstrings/pluto_source_pydoc_template.h
deleted file mode 100644
index 84d8174642..0000000000
--- a/gr-iio/python/iio/bindings/docstrings/pluto_source_pydoc_template.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2020 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-#include "pydoc_macros.h"
-#define D(...) DOC(gr, iio, __VA_ARGS__)
-/*
- This file contains placeholders for docstrings for the Python bindings.
- Do not edit! These were automatically extracted during the binding process
- and will be overwritten during the build process
- */
-
-static const char* __doc_gr_iio_pluto_source = R"doc()doc";
-
-static const char* __doc_gr_iio_pluto_source_make = R"doc()doc";
-
-static const char* __doc_gr_iio_pluto_source_set_params = R"doc()doc";
-
-static const char* __doc_gr_iio_pluto_source_set_len_tag_key = R"doc()doc";
diff --git a/gr-iio/python/iio/bindings/docstrings/pluto_sink_pydoc_template.h b/gr-iio/python/iio/bindings/docstrings/pluto_utils_pydoc_template.h
index e24658eab8..1308bf2733 100644
--- a/gr-iio/python/iio/bindings/docstrings/pluto_sink_pydoc_template.h
+++ b/gr-iio/python/iio/bindings/docstrings/pluto_utils_pydoc_template.h
@@ -14,10 +14,4 @@
and will be overwritten during the build process
*/
-static const char* __doc_gr_iio_pluto_sink = R"doc()doc";
-
-static const char* __doc_gr_iio_pluto_sink_make = R"doc()doc";
-
-static const char* __doc_gr_iio_pluto_sink_set_params = R"doc()doc";
-
-static const char* __doc_gr_iio_pluto_sink_set_len_tag_key = R"doc()doc";
+static const char* __doc_gr_iio_pluto_utils_get_pluto_uri = R"doc()doc";
diff --git a/gr-iio/python/iio/bindings/fmcomms2_sink_f32c_python.cc b/gr-iio/python/iio/bindings/fmcomms2_sink_f32c_python.cc
deleted file mode 100644
index e99c691c5c..0000000000
--- a/gr-iio/python/iio/bindings/fmcomms2_sink_f32c_python.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2020 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-/***********************************************************************************/
-/* This file is automatically generated using bindtool and can be manually edited */
-/* The following lines can be configured to regenerate this file during cmake */
-/* If manual edits are made, the following tags should be modified accordingly. */
-/* BINDTOOL_GEN_AUTOMATIC(0) */
-/* BINDTOOL_USE_PYGCCXML(0) */
-/* BINDTOOL_HEADER_FILE(fmcomms2_sink_fc32.h) */
-/* BINDTOOL_HEADER_FILE_HASH(22973a1c4b186c5b8363b99d601da6b5) */
-/***********************************************************************************/
-
-#include <pybind11/complex.h>
-#include <pybind11/pybind11.h>
-#include <pybind11/stl.h>
-
-namespace py = pybind11;
-
-#include <gnuradio/iio/fmcomms2_sink_fc32.h>
-// pydoc.h is automatically generated in the build directory
-#include <fmcomms2_sink_f32c_pydoc.h>
-
-void bind_fmcomms2_sink_f32c(py::module& m)
-{
-
- using fmcomms2_sink_f32c = gr::iio::fmcomms2_sink_f32c;
-
-
- py::class_<fmcomms2_sink_f32c,
- gr::hier_block2,
- gr::basic_block,
- std::shared_ptr<fmcomms2_sink_f32c>>(
- m, "fmcomms2_sink_f32c", D(fmcomms2_sink_f32c))
-
- .def(py::init(&fmcomms2_sink_f32c::make),
- py::arg("uri"),
- py::arg("longfrequency"),
- py::arg("samplerate"),
- py::arg("bandwidth"),
- py::arg("tx1_en"),
- py::arg("tx2_en"),
- py::arg("buffer_size"),
- py::arg("cyclic"),
- py::arg("rf_port_select"),
- py::arg("attenuation1"),
- py::arg("attenuation2"),
- py::arg("filter_source") = "",
- py::arg("filter_filename") = "",
- py::arg("Fpass") = 0.0,
- py::arg("Fstop") = 0.0,
- D(fmcomms2_sink_f32c, make))
-
- .def("set_params",
- &fmcomms2_sink_f32c::set_params,
- py::arg("longfrequency"),
- py::arg("samplerate"),
- py::arg("bandwidth"),
- py::arg("rf_port_select"),
- py::arg("attenuation1"),
- py::arg("attenuation2"),
- py::arg("filter_source") = "",
- py::arg("filter_filename") = "",
- py::arg("Fpass") = 0.0,
- py::arg("Fstop") = 0.0,
- D(fmcomms2_sink_f32c, set_params))
-
- ;
-}
diff --git a/gr-iio/python/iio/bindings/fmcomms2_sink_python.cc b/gr-iio/python/iio/bindings/fmcomms2_sink_python.cc
index 2c98a0c8c3..c6c879f3ca 100644
--- a/gr-iio/python/iio/bindings/fmcomms2_sink_python.cc
+++ b/gr-iio/python/iio/bindings/fmcomms2_sink_python.cc
@@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(fmcomms2_sink.h) */
-/* BINDTOOL_HEADER_FILE_HASH(1ca54fa74c12834cae56b0832dd5c3f3) */
+/* BINDTOOL_HEADER_FILE_HASH(0cc01ab33946f58b5c4056a61d6043c4) */
/***********************************************************************************/
#include <pybind11/complex.h>
@@ -27,51 +27,48 @@ namespace py = pybind11;
// pydoc.h is automatically generated in the build directory
#include <fmcomms2_sink_pydoc.h>
-void bind_fmcomms2_sink(py::module& m)
+
+template <typename T>
+void bind_fmcomms2_sink_template(py::module& m, const char* classname)
{
- using fmcomms2_sink = gr::iio::fmcomms2_sink;
+ using fmcomms2_sink = gr::iio::fmcomms2_sink<T>;
py::class_<fmcomms2_sink,
gr::sync_block,
gr::block,
gr::basic_block,
- std::shared_ptr<fmcomms2_sink>>(m, "fmcomms2_sink", D(fmcomms2_sink))
+ std::shared_ptr<fmcomms2_sink>>(m, classname, D(fmcomms2_sink))
+
.def(py::init(&fmcomms2_sink::make),
py::arg("uri"),
- py::arg("longfrequency"),
- py::arg("samplerate"),
- py::arg("bandwidth"),
- py::arg("ch1_en"),
- py::arg("ch2_en"),
- py::arg("ch3_en"),
- py::arg("ch4_en"),
+ py::arg("ch_en"),
py::arg("buffer_size"),
py::arg("cyclic"),
- py::arg("rf_port_select"),
- py::arg("attenuation1"),
- py::arg("attenuation2"),
- py::arg("filter_source") = "",
- py::arg("filter_filename") = "",
- py::arg("Fpass") = 0.0,
- py::arg("Fstop") = 0.0,
D(fmcomms2_sink, make))
-
- .def("set_params",
- &fmcomms2_sink::set_params,
- py::arg("longfrequency"),
- py::arg("samplerate"),
- py::arg("bandwidth"),
- py::arg("rf_port_select"),
- py::arg("attenuation1"),
- py::arg("attenuation2"),
- py::arg("filter_source") = "",
+ .def("set_bandwidth", &fmcomms2_sink::set_bandwidth, py::arg("longbandwidth"))
+ .def("set_frequency", &fmcomms2_sink::set_frequency, py::arg("longfrequency"))
+ .def("set_samplerate", &fmcomms2_sink::set_samplerate, py::arg("samplerate"))
+ .def("set_attenuation",
+ &fmcomms2_sink::set_attenuation,
+ py::arg("chan"),
+ py::arg("attenuation"))
+ .def("set_filter_params",
+ &fmcomms2_sink::set_filter_params,
+ py::arg("filter_source"),
py::arg("filter_filename") = "",
- py::arg("Fpass") = 0.0,
- py::arg("Fstop") = 0.0,
- D(fmcomms2_sink, set_params))
+ py::arg("fpass") = 0.0,
+ py::arg("fstop") = 0.0)
+ .def("set_len_tag_key",
+ &fmcomms2_sink::set_len_tag_key,
+ py::arg("len_tag_key") = "");
+}
- ;
+void bind_fmcomms2_sink(py::module& m)
+{
+ bind_fmcomms2_sink_template<int16_t>(m, "fmcomms2_sink_s");
+ bind_fmcomms2_sink_template<std::complex<int16_t>>(m, "fmcomms2_sink_sc16");
+ bind_fmcomms2_sink_template<gr_complex>(m, "fmcomms2_sink_fc32");
}
diff --git a/gr-iio/python/iio/bindings/fmcomms2_source_f32c_python.cc b/gr-iio/python/iio/bindings/fmcomms2_source_f32c_python.cc
deleted file mode 100644
index 57a0ce0cfa..0000000000
--- a/gr-iio/python/iio/bindings/fmcomms2_source_f32c_python.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2020 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-/***********************************************************************************/
-/* This file is automatically generated using bindtool and can be manually edited */
-/* The following lines can be configured to regenerate this file during cmake */
-/* If manual edits are made, the following tags should be modified accordingly. */
-/* BINDTOOL_GEN_AUTOMATIC(0) */
-/* BINDTOOL_USE_PYGCCXML(0) */
-/* BINDTOOL_HEADER_FILE(fmcomms2_source_fc32.h) */
-/* BINDTOOL_HEADER_FILE_HASH(dde70331e3284513f54d0d26df960535) */
-/***********************************************************************************/
-
-#include <pybind11/complex.h>
-#include <pybind11/pybind11.h>
-#include <pybind11/stl.h>
-
-namespace py = pybind11;
-
-#include <gnuradio/iio/fmcomms2_source_fc32.h>
-// pydoc.h is automatically generated in the build directory
-#include <fmcomms2_source_f32c_pydoc.h>
-
-void bind_fmcomms2_source_f32c(py::module& m)
-{
-
- using fmcomms2_source_f32c = gr::iio::fmcomms2_source_f32c;
-
-
- py::class_<fmcomms2_source_f32c,
- gr::hier_block2,
- gr::basic_block,
- std::shared_ptr<fmcomms2_source_f32c>>(
- m, "fmcomms2_source_f32c", D(fmcomms2_source_f32c))
-
- .def(py::init(&fmcomms2_source_f32c::make),
- py::arg("uri"),
- py::arg("ch_en"),
- py::arg("buffer_size"),
- D(fmcomms2_source_f32c, make))
-
- // .def("set_params",
- // &fmcomms2_source_f32c::set_params,
- // py::arg("longfrequency"),
- // py::arg("samplerate"),
- // py::arg("bandwidth"),
- // py::arg("quadrature"),
- // py::arg("rfdc"),
- // py::arg("bbdc"),
- // py::arg("gain1"),
- // py::arg("gain1_value"),
- // py::arg("gain2"),
- // py::arg("gain2_value"),
- // py::arg("rf_port_select"),
- // py::arg("filter_source") = "",
- // py::arg("filter_filename") = "",
- // py::arg("Fpass") = 0.0,
- // py::arg("Fstop") = 0.0,
- // D(fmcomms2_source_f32c, set_params))
-
- ;
-}
diff --git a/gr-iio/python/iio/bindings/fmcomms2_source_python.cc b/gr-iio/python/iio/bindings/fmcomms2_source_python.cc
index 636c4127d9..a69a1424e1 100644
--- a/gr-iio/python/iio/bindings/fmcomms2_source_python.cc
+++ b/gr-iio/python/iio/bindings/fmcomms2_source_python.cc
@@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(fmcomms2_source.h) */
-/* BINDTOOL_HEADER_FILE_HASH(79999a9f1335aa4bc5043ddf033a0e38) */
+/* BINDTOOL_HEADER_FILE_HASH(c286f60f1afed36dfc335cf4ce1b949e) */
/***********************************************************************************/
#include <pybind11/complex.h>
@@ -27,23 +27,46 @@ namespace py = pybind11;
// pydoc.h is automatically generated in the build directory
#include <fmcomms2_source_pydoc.h>
-void bind_fmcomms2_source(py::module& m)
+template <typename T>
+void bind_fmcomms2_source_template(py::module& m, const char* classname)
{
- using fmcomms2_source = gr::iio::fmcomms2_source;
+ using fmcomms2_source = gr::iio::fmcomms2_source<T>;
py::class_<fmcomms2_source,
gr::sync_block,
gr::block,
gr::basic_block,
- std::shared_ptr<fmcomms2_source>>(m, "fmcomms2_source", D(fmcomms2_source))
+ std::shared_ptr<fmcomms2_source>>(m, classname, D(fmcomms2_source))
.def(py::init(&fmcomms2_source::make),
py::arg("uri"),
py::arg("ch_en"),
py::arg("buffer_size"),
D(fmcomms2_source, make))
+ .def("set_frequency", &fmcomms2_source::set_frequency, py::arg("longfrequency"))
+ .def("set_samplerate", &fmcomms2_source::set_samplerate, py::arg("samplerate"))
+ .def("set_gain_mode",
+ &fmcomms2_source::set_gain_mode,
+ py::arg("chan"),
+ py::arg("mode"))
+ .def("set_gain",
+ &fmcomms2_source::set_gain,
+ py::arg("chan"),
+ py::arg("gain_value"))
+ .def("set_quadrature", &fmcomms2_source::set_quadrature, py::arg("quadrature"))
+ .def("set_rfdc", &fmcomms2_source::set_rfdc, py::arg("rfdc"))
+ .def("set_bbdc", &fmcomms2_source::set_bbdc, py::arg("bbdc"))
+ .def("set_filter_params", &fmcomms2_source::set_filter_params)
+ .def(
+ "set_len_tag_key", &fmcomms2_source::set_len_tag_key, py::arg("len_tag_key"));
+ ;
+}
- ;
+void bind_fmcomms2_source(py::module& m)
+{
+ bind_fmcomms2_source_template<int16_t>(m, "fmcomms2_source_s");
+ bind_fmcomms2_source_template<std::complex<int16_t>>(m, "fmcomms2_source_sc16");
+ bind_fmcomms2_source_template<gr_complex>(m, "fmcomms2_source_fc32");
}
diff --git a/gr-iio/python/iio/bindings/fmcomms5_sink_f32c_python.cc b/gr-iio/python/iio/bindings/fmcomms5_sink_f32c_python.cc
deleted file mode 100644
index 925a8ad209..0000000000
--- a/gr-iio/python/iio/bindings/fmcomms5_sink_f32c_python.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2020 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-/***********************************************************************************/
-/* This file is automatically generated using bindtool and can be manually edited */
-/* The following lines can be configured to regenerate this file during cmake */
-/* If manual edits are made, the following tags should be modified accordingly. */
-/* BINDTOOL_GEN_AUTOMATIC(0) */
-/* BINDTOOL_USE_PYGCCXML(0) */
-/* BINDTOOL_HEADER_FILE(fmcomms5_sink.h) */
-/* BINDTOOL_HEADER_FILE_HASH(21d1c8134dce260caa1564aaaff30d09) */
-/***********************************************************************************/
-
-#include <pybind11/complex.h>
-#include <pybind11/pybind11.h>
-#include <pybind11/stl.h>
-
-namespace py = pybind11;
-
-#include <gnuradio/iio/fmcomms5_sink.h>
-// pydoc.h is automatically generated in the build directory
-#include <fmcomms5_sink_f32c_pydoc.h>
-
-void bind_fmcomms5_sink_f32c(py::module& m)
-{
-
- using fmcomms5_sink_f32c = gr::iio::fmcomms5_sink_f32c;
-
-
- py::class_<fmcomms5_sink_f32c,
- gr::hier_block2,
- gr::basic_block,
- std::shared_ptr<fmcomms5_sink_f32c>>(
- m, "fmcomms5_sink_f32c", D(fmcomms5_sink_f32c))
-
- .def(py::init(&fmcomms5_sink_f32c::make),
- py::arg("uri"),
- py::arg("longfrequency1"),
- py::arg("longfrequency2"),
- py::arg("samplerate"),
- py::arg("bandwidth"),
- py::arg("tx1_en"),
- py::arg("tx2_en"),
- py::arg("tx3_en"),
- py::arg("tx4_en"),
- py::arg("buffer_size"),
- py::arg("cyclic"),
- py::arg("rf_port_select"),
- py::arg("attenuation1"),
- py::arg("attenuation2"),
- py::arg("attenuation3"),
- py::arg("attenuation4"),
- py::arg("filter_source") = "",
- py::arg("filter_filename") = "",
- py::arg("Fpass") = 0.0,
- py::arg("Fstop") = 0.0,
- D(fmcomms5_sink_f32c, make))
-
- .def("set_params",
- &fmcomms5_sink_f32c::set_params,
- py::arg("longfrequency1"),
- py::arg("longfrequency2"),
- py::arg("samplerate"),
- py::arg("bandwidth"),
- py::arg("rf_port_select"),
- py::arg("attenuation1"),
- py::arg("attenuation2"),
- py::arg("attenuation3"),
- py::arg("attenuation4"),
- py::arg("filter_source") = "",
- py::arg("filter_filename") = "",
- py::arg("Fpass") = 0.0,
- py::arg("Fstop") = 0.0,
- D(fmcomms5_sink_f32c, set_params))
-
- ;
-}
diff --git a/gr-iio/python/iio/bindings/fmcomms5_source_f32c_python.cc b/gr-iio/python/iio/bindings/fmcomms5_source_f32c_python.cc
deleted file mode 100644
index 95816d4f31..0000000000
--- a/gr-iio/python/iio/bindings/fmcomms5_source_f32c_python.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2020 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-/***********************************************************************************/
-/* This file is automatically generated using bindtool and can be manually edited */
-/* The following lines can be configured to regenerate this file during cmake */
-/* If manual edits are made, the following tags should be modified accordingly. */
-/* BINDTOOL_GEN_AUTOMATIC(0) */
-/* BINDTOOL_USE_PYGCCXML(0) */
-/* BINDTOOL_HEADER_FILE(fmcomms5_source.h) */
-/* BINDTOOL_HEADER_FILE_HASH(6db6b174251b0437df60bd5d117bc5ee) */
-/***********************************************************************************/
-
-#include <pybind11/complex.h>
-#include <pybind11/pybind11.h>
-#include <pybind11/stl.h>
-
-namespace py = pybind11;
-
-#include <gnuradio/iio/fmcomms5_source.h>
-// pydoc.h is automatically generated in the build directory
-#include <fmcomms5_source_f32c_pydoc.h>
-
-void bind_fmcomms5_source_f32c(py::module& m)
-{
-
- using fmcomms5_source_f32c = gr::iio::fmcomms5_source_f32c;
-
-
- py::class_<fmcomms5_source_f32c,
- gr::hier_block2,
- gr::basic_block,
- std::shared_ptr<fmcomms5_source_f32c>>(
- m, "fmcomms5_source_f32c", D(fmcomms5_source_f32c))
-
- .def(py::init(&fmcomms5_source_f32c::make),
- py::arg("uri"),
- py::arg("longfrequency1"),
- py::arg("longfrequency2"),
- py::arg("samplerate"),
- py::arg("bandwidth"),
- py::arg("tx1_en"),
- py::arg("tx2_en"),
- py::arg("tx3_en"),
- py::arg("tx4_en"),
- py::arg("buffer_size"),
- py::arg("quadrature"),
- py::arg("rfdc"),
- py::arg("bbdc"),
- py::arg("gain1"),
- py::arg("gain1_value"),
- py::arg("gain2"),
- py::arg("gain2_value"),
- py::arg("gain3"),
- py::arg("gain3_value"),
- py::arg("gain4"),
- py::arg("gain4_value"),
- py::arg("rf_port_select"),
- py::arg("filter_source") = "",
- py::arg("filter_filename") = "",
- py::arg("Fpass") = 0.0,
- py::arg("Fstop") = 0.0,
- D(fmcomms5_source_f32c, make))
-
- .def("set_params",
- &fmcomms5_source_f32c::set_params,
- py::arg("longfrequency1"),
- py::arg("longfrequency2"),
- py::arg("samplerate"),
- py::arg("bandwidth"),
- py::arg("quadrature"),
- py::arg("rfdc"),
- py::arg("bbdc"),
- py::arg("gain1"),
- py::arg("gain1_value"),
- py::arg("gain2"),
- py::arg("gain2_value"),
- py::arg("gain3"),
- py::arg("gain3_value"),
- py::arg("gain4"),
- py::arg("gain4_value"),
- py::arg("rf_port_select"),
- py::arg("filter_source") = "",
- py::arg("filter_filename") = "",
- py::arg("Fpass") = 0.0,
- py::arg("Fstop") = 0.0,
- D(fmcomms5_source_f32c, set_params))
-
- ;
-}
diff --git a/gr-iio/python/iio/bindings/pluto_sink_python.cc b/gr-iio/python/iio/bindings/pluto_sink_python.cc
deleted file mode 100644
index 2d1a2fa63d..0000000000
--- a/gr-iio/python/iio/bindings/pluto_sink_python.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2020 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-/***********************************************************************************/
-/* This file is automatically generated using bindtool and can be manually edited */
-/* The following lines can be configured to regenerate this file during cmake */
-/* If manual edits are made, the following tags should be modified accordingly. */
-/* BINDTOOL_GEN_AUTOMATIC(0) */
-/* BINDTOOL_USE_PYGCCXML(0) */
-/* BINDTOOL_HEADER_FILE(pluto_sink.h) */
-/* BINDTOOL_HEADER_FILE_HASH(4315d0abebcaff67b262aee785fb2c49) */
-/***********************************************************************************/
-
-#include <pybind11/complex.h>
-#include <pybind11/pybind11.h>
-#include <pybind11/stl.h>
-
-namespace py = pybind11;
-
-#include <gnuradio/iio/pluto_sink.h>
-// pydoc.h is automatically generated in the build directory
-#include <pluto_sink_pydoc.h>
-
-void bind_pluto_sink(py::module& m)
-{
-
- using pluto_sink = gr::iio::pluto_sink;
-
- py::class_<pluto_sink, gr::hier_block2, gr::basic_block, std::shared_ptr<pluto_sink>>(
- m, "pluto_sink", D(pluto_sink))
-
- .def(py::init(&pluto_sink::make),
- py::arg("uri"),
- py::arg("buffer_size"),
- py::arg("cyclic"),
- D(pluto_sink, make))
-
- .def("set_bandwidth", &pluto_sink::set_bandwidth, py::arg("longbandwidth"))
- .def("set_frequency", &pluto_sink::set_frequency, py::arg("longfrequency"))
- .def("set_samplerate", &pluto_sink::set_samplerate, py::arg("samplerate"))
- .def("set_attenuation", &pluto_sink::set_attenuation, py::arg("attenuation"))
- .def("set_filter_params", &pluto_sink::set_filter_params)
- .def(
- "set_len_tag_key", &pluto_sink::set_len_tag_key, py::arg("len_tag_key") = "");
-}
diff --git a/gr-iio/python/iio/bindings/pluto_source_python.cc b/gr-iio/python/iio/bindings/pluto_source_python.cc
deleted file mode 100644
index e284b92b15..0000000000
--- a/gr-iio/python/iio/bindings/pluto_source_python.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2020 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-/***********************************************************************************/
-/* This file is automatically generated using bindtool and can be manually edited */
-/* The following lines can be configured to regenerate this file during cmake */
-/* If manual edits are made, the following tags should be modified accordingly. */
-/* BINDTOOL_GEN_AUTOMATIC(0) */
-/* BINDTOOL_USE_PYGCCXML(0) */
-/* BINDTOOL_HEADER_FILE(pluto_source.h) */
-/* BINDTOOL_HEADER_FILE_HASH(f73fc3ad843eb6f61c8a520ee3d68f8f) */
-/***********************************************************************************/
-
-#include <pybind11/complex.h>
-#include <pybind11/pybind11.h>
-#include <pybind11/stl.h>
-
-namespace py = pybind11;
-
-#include <gnuradio/iio/pluto_source.h>
-// pydoc.h is automatically generated in the build directory
-#include <pluto_source_pydoc.h>
-
-void bind_pluto_source(py::module& m)
-{
-
- using pluto_source = gr::iio::pluto_source;
-
- py::class_<pluto_source,
- gr::hier_block2,
- gr::basic_block,
- std::shared_ptr<pluto_source>>(m, "pluto_source", D(pluto_source))
-
- .def(py::init(&pluto_source::make),
- py::arg("uri"),
- py::arg("buffer_size"),
- D(pluto_source, make))
-
- .def("set_frequency", &pluto_source::set_frequency, py::arg("longfrequency"))
- .def("set_samplerate", &pluto_source::set_samplerate, py::arg("samplerate"))
- .def("set_gain_mode", &pluto_source::set_gain_mode, py::arg("mode"))
- .def("set_gain", &pluto_source::set_gain, py::arg("gain_value"))
- .def("set_quadrature", &pluto_source::set_quadrature, py::arg("quadrature"))
- .def("set_rfdc", &pluto_source::set_rfdc, py::arg("rfdc"))
- .def("set_bbdc", &pluto_source::set_bbdc, py::arg("bbdc"))
- .def("set_filter_params", &pluto_source::set_filter_params)
- .def("set_len_tag_key", &pluto_source::set_len_tag_key, py::arg("len_tag_key"));
- ;
-}
diff --git a/gr-iio/python/iio/bindings/pluto_utils_python.cc b/gr-iio/python/iio/bindings/pluto_utils_python.cc
new file mode 100644
index 0000000000..dd9c47f6fc
--- /dev/null
+++ b/gr-iio/python/iio/bindings/pluto_utils_python.cc
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+/***********************************************************************************/
+/* This file is automatically generated using bindtool and can be manually edited */
+/* The following lines can be configured to regenerate this file during cmake */
+/* If manual edits are made, the following tags should be modified accordingly. */
+/* BINDTOOL_GEN_AUTOMATIC(0) */
+/* BINDTOOL_USE_PYGCCXML(0) */
+/* BINDTOOL_HEADER_FILE(pluto_utils.h) */
+/* BINDTOOL_HEADER_FILE_HASH(0955a4f40cd1fe794602d5e1af340c63) */
+/***********************************************************************************/
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/iio/pluto_utils.h>
+// pydoc.h is automatically generated in the build directory
+#include <pluto_utils_pydoc.h>
+
+void bind_pluto_utils(py::module& m)
+{
+
+ m.def("get_pluto_uri", &gr::iio::get_pluto_uri, D(pluto_utils, get_pluto_uri));
+}
diff --git a/gr-iio/python/iio/bindings/python_bindings.cc b/gr-iio/python/iio/bindings/python_bindings.cc
index f264e2c10c..869e9d8703 100644
--- a/gr-iio/python/iio/bindings/python_bindings.cc
+++ b/gr-iio/python/iio/bindings/python_bindings.cc
@@ -22,16 +22,13 @@ void bind_attr_sink(py::module& m);
void bind_dds_control(py::module& m);
void bind_attr_updater(py::module& m);
#ifdef GR_IIO_LIBAD9361
-// void bind_fmcomms2_sink(py::module& m);
-// void bind_fmcomms2_sink_f32c(py::module& m);
+void bind_fmcomms2_sink(py::module& m);
// void bind_fmcomms5_sink(py::module& m);
// void bind_fmcomms5_sink_f32c(py::module& m);
-// void bind_fmcomms2_source(py::module& m);
-// void bind_fmcomms2_source_f32c(py::module& m);
+void bind_fmcomms2_source(py::module& m);
// void bind_fmcomms5_source(py::module& m);
// void bind_fmcomms5_source_f32c(py::module& m);
-void bind_pluto_sink(py::module& m);
-void bind_pluto_source(py::module& m);
+void bind_pluto_utils(py::module& m);
#endif
// We need this hack because import_array() returns NULL
@@ -61,15 +58,12 @@ PYBIND11_MODULE(iio_python, m)
bind_dds_control(m);
bind_attr_updater(m);
#ifdef GR_IIO_LIBAD9361
- // bind_fmcomms2_sink(m);
- // bind_fmcomms2_sink_f32c(m);
+ bind_fmcomms2_sink(m);
// bind_fmcomms5_sink(m);
// bind_fmcomms5_sink_f32c(m);
- bind_pluto_sink(m);
- // bind_fmcomms2_source(m);
- // bind_fmcomms2_source_f32c(m);
+ bind_fmcomms2_source(m);
// bind_fmcomms5_source(m);
// bind_fmcomms5_source_f32c(m);
- bind_pluto_source(m);
+ bind_pluto_utils(m);
#endif
}