GNU Radio's IIO Package
attr_source_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2018 Analog Devices Inc.
4  * Author: Travis Collins <travis.collins@analog.com>
5  *
6  * This is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this software; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef INCLUDED_IIO_ATTR_SOURCE_IMPL_H
23 #define INCLUDED_IIO_ATTR_SOURCE_IMPL_H
24 
25 #include <iio/attr_source.h>
26 #include <vector>
27 
28 #include "device_source_impl.h"
29 
30 namespace gr {
31  namespace iio {
32 
34  {
35  private:
36  std::string device;
37  std::string channel;
38  std::string uri;
39  std::string attribute;
40  int update_interval_ms;
41  int samples_per_update;
42  int data_type;
43  int attr_type;
44  int m_attr_type;
45  bool output;
46  int ret;
47  uint32_t address;
48  bool required_enable;
49 
50  protected:
51  struct iio_context *ctx;
52  struct iio_device *dev;
53  struct iio_channel * chan;
54 
55  public:
56  attr_source_impl(const std::string &uri, const std::string &device, const std::string &channel,
57  const std::string &attribute, int update_interval_ms, int samples_per_update,
58  int data_type, int attr_type, bool output, uint32_t address, bool required_enable);
60 
61  // Where all the action really happens
62  int work(int noutput_items,
63  gr_vector_const_void_star &input_items,
64  gr_vector_void_star &output_items);
65 
66  size_t type_sizeof(int data_type, int attr_type);
67  void get_attribute_data(const std::string& attribute, double* value);
68  void get_attribute_data(const std::string& attribute, float* value);
69  void get_attribute_data(const std::string& attribute, long long* value);
70  void get_attribute_data(const std::string& attribute, int* value);
71  void get_attribute_data(const std::string& attribute, uint8_t* value);
72  void get_register_data(uint32_t address, int* value);
73  void check(int ret);
74 
75  };
76 
77  } // namespace iio
78 } // namespace gr
79 
80 #endif /* INCLUDED_IIO_ATTR_SOURCE_IMPL_H */
struct iio_context * ctx
Definition: attr_source_impl.h:51
attr_source_impl(const std::string &uri, const std::string &device, const std::string &channel, const std::string &attribute, int update_interval_ms, int samples_per_update, int data_type, int attr_type, bool output, uint32_t address, bool required_enable)
size_t type_sizeof(int data_type, int attr_type)
void get_register_data(uint32_t address, int *value)
Definition: attr_source_impl.h:33
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
Definition: attr_sink.h:29
<+description of block+>
Definition: attr_source.h:37
struct iio_channel * chan
Definition: attr_source_impl.h:53
struct iio_device * dev
Definition: attr_source_impl.h:52
void get_attribute_data(const std::string &attribute, double *value)