GNU Radio Manual and C++ API Reference  3.10.9.1
The Free & Open Software Radio Ecosystem
device_source.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_SOURCE_H
12 #define INCLUDED_IIO_DEVICE_SOURCE_H
13 
14 #include <gnuradio/iio/api.h>
15 #include <gnuradio/iio/iio_types.h>
16 #include <gnuradio/sync_block.h>
17 
18 
19 #define DEFAULT_BUFFER_SIZE 0x8000
20 
21 extern "C" {
22 struct iio_context;
23 };
24 
25 namespace gr {
26 namespace iio {
27 
28 /*!
29  * \brief Generic source for IIO drivers with buffered output channels
30  * \ingroup iio
31  *
32  * \details
33  * This block allows for streaming data from any IIO driver which has output
34  * scan elements or buffered channels.
35  */
36 class IIO_API device_source : virtual public gr::sync_block
37 {
38 public:
39  typedef std::shared_ptr<device_source> sptr;
40 
41  /*!
42  * \brief Return a shared_ptr to a new instance of iio::device.
43  *
44  * \param uri String of the context uri
45  * \param device String of device name
46  * \param channels Vector of strings of channels names
47  * \param device_phy String of phy device name where attribute updates are
48  * applied
49  * \param params Vector of strings of attributes to set in form:
50  * "<attribute name>=<value to set>,<attribute name>=<value to set>"
51  * \param buffer_size Integer number of samples to be put into each IIO
52  * buffered passed to hardware.
53  * \param decimation Integer number of sample to remove from received
54  * data buffers between successive samples
55  */
56  static sptr make(const std::string& uri,
57  const std::string& device,
58  const std::vector<std::string>& channels,
59  const std::string& device_phy,
60  const iio_param_vec_t& params,
61  unsigned int buffer_size = DEFAULT_BUFFER_SIZE,
62  unsigned int decimation = 0);
63 
64  static sptr make_from(iio_context* ctx,
65  const std::string& device,
66  const std::vector<std::string>& channels,
67  const std::string& device_phy,
68  const iio_param_vec_t& params,
69  unsigned int buffer_size = DEFAULT_BUFFER_SIZE,
70  unsigned int decimation = 0);
71 
72  /*!
73  * \brief Key of the packet length tag. If empty no tag will be emitted
74  */
75  virtual void set_len_tag_key(const std::string& len_tag_key) = 0;
76 
77  /*!
78  * \brief Number of samples to be put into each IIO
79  * buffered passed to hardware.
80  */
81  virtual void set_buffer_size(unsigned int buffer_size) = 0;
82 
83  virtual void set_timeout_ms(unsigned long timeout) = 0;
84 };
85 
86 } // namespace iio
87 } // namespace gr
88 
89 #endif /* INCLUDED_IIO_DEVICE_SOURCE_H */
Generic source for IIO drivers with buffered output channels.
Definition: device_source.h:37
virtual void set_timeout_ms(unsigned long timeout)=0
std::shared_ptr< device_source > sptr
Definition: device_source.h:39
virtual void set_len_tag_key(const std::string &len_tag_key)=0
Key of the packet length tag. If empty no tag will be emitted.
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 decimation=0)
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 decimation=0)
Return a shared_ptr to a new instance of iio::device.
virtual void set_buffer_size(unsigned int buffer_size)=0
Number of samples to be put into each IIO buffered passed to hardware.
synchronous 1:1 input to output with history
Definition: sync_block.h:26
#define DEFAULT_BUFFER_SIZE
Definition: device_source.h:19
#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