GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
device_sink.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2014 Analog Devices Inc.
4  * Author: Paul Cercueil <paul.cercueil@analog.com>
5  *
6  * SPDX-License-Identifier: GPL-3.0-or-later
7  *
8  */
9 
10 
11 #ifndef INCLUDED_IIO_DEVICE_SINK_H
12 #define INCLUDED_IIO_DEVICE_SINK_H
13 
14 #include <gnuradio/iio/api.h>
15 #include <gnuradio/iio/iio_types.h>
16 #include <gnuradio/sync_block.h>
17 
18 #include <string>
19 
20 #define DEFAULT_BUFFER_SIZE 0x8000
21 
22 extern "C" {
23 struct iio_context;
24 };
25 
26 namespace gr {
27 namespace iio {
28 
29 /*!
30  * \brief Generic sink for IIO drivers with buffered input channels
31  * \ingroup iio
32  *
33  * \details
34  * This block allows for streaming data to any IIO driver which has input
35  * scan elements or buffered channels.
36  */
37 class IIO_API device_sink : virtual public gr::sync_block
38 {
39 public:
40  typedef std::shared_ptr<device_sink> sptr;
41 
42  /*!
43  * \brief Return a shared_ptr to a new instance of iio::device.
44  *
45  * \param uri String of the context uri
46  * \param device String of device name
47  * \param channels Vector of strings of channels names
48  * \param device_phy String of phy device name where attribute updates are
49  * applied
50  * \param params Vector of strings of attributes to set in form:
51  * "<attribute name>=<value to set>,<attribute name>=<value to set>"
52  * \param buffer_size Integer number of samples to be put into each IIO
53  * buffered passed to hardware.
54  * \param interpolation Integer number of zeros to insert into transmit
55  * transmit buffers between samples
56  * \param cyclic Boolean when True sends first buffer_size number of samples
57  * to hardware which is repeated in the hardware itself. Future
58  * samples are ignored.
59  */
60  static sptr make(const std::string& uri,
61  const std::string& device,
62  const std::vector<std::string>& channels,
63  const std::string& device_phy,
64  const iio_param_vec_t& params,
65  unsigned int buffer_size = DEFAULT_BUFFER_SIZE,
66  unsigned int interpolation = 0,
67  bool cyclic = false);
68 
69  static sptr make_from(iio_context* ctx,
70  const std::string& device,
71  const std::vector<std::string>& channels,
72  const std::string& device_phy,
73  const iio_param_vec_t& params,
74  unsigned int buffer_size = DEFAULT_BUFFER_SIZE,
75  unsigned int interpolation = 0,
76  bool cyclic = false);
77 
78  /*!
79  * The key of the tag that indicates packet length.
80  * When not empty, samples are expected as "packets" and
81  * must be tagged as such, i.e. the first sample of a packet needs to be
82  * tagged with the corresponding length of that packet.
83  * Note, packet size MUST be equal to buffer_size / (1+interpolation),
84  * otherwise a runtime_error will be thrown. This is a deliberate design
85  * choice, because all other options would result in potentially unexpected
86  * behavior.
87  */
88  virtual void set_len_tag_key(const std::string& len_tag_key) = 0;
89 };
90 
91 } // namespace iio
92 } // namespace gr
93 
94 #endif /* INCLUDED_IIO_DEVICE_SINK_H */
Generic sink for IIO drivers with buffered input channels.
Definition: device_sink.h:38
std::shared_ptr< device_sink > sptr
Definition: device_sink.h:40
static sptr make_from(iio_context *ctx, const std::string &device, const std::vector< std::string > &channels, const std::string &device_phy, const iio_param_vec_t &params, unsigned int buffer_size=DEFAULT_BUFFER_SIZE, unsigned int interpolation=0, bool cyclic=false)
static sptr make(const std::string &uri, const std::string &device, const std::vector< std::string > &channels, const std::string &device_phy, const iio_param_vec_t &params, unsigned int buffer_size=DEFAULT_BUFFER_SIZE, unsigned int interpolation=0, bool cyclic=false)
Return a shared_ptr to a new instance of iio::device.
virtual void set_len_tag_key(const std::string &len_tag_key)=0
synchronous 1:1 input to output with history
Definition: sync_block.h:26
#define DEFAULT_BUFFER_SIZE
Definition: device_sink.h:20
#define IIO_API
Definition: gr-iio/include/gnuradio/iio/api.h:18
std::vector< iio_param_t > iio_param_vec_t
Definition: iio_types.h:44
GNU Radio logging wrapper.
Definition: basic_block.h:29