58 virtual void onIioEvent(
const IioEventData& eventData) = 0;
86 std::ostringstream oss;
87 oss <<
"IIO device " << device <<
" is not valid";
88 throw std::invalid_argument(oss.str());
99 Iio(
const std::string& deviceName)
101 std::ostringstream oss;
104 oss <<
"IIO device name " << deviceName <<
" not found";
105 throw std::invalid_argument(oss.str());
109 oss <<
"IIO device " << deviceName <<
" is not valid";
110 throw std::invalid_argument(oss.str());
123 throw std::invalid_argument(
"Invalid IIO context");
157 readInt(
const std::string& attributeName)
const 162 std::ostringstream oss;
163 oss <<
"IIO readInt for attibute " << attributeName <<
" failed";
164 throw std::runtime_error(oss.str());
184 std::ostringstream oss;
185 oss <<
"IIO readFloat for attibute " << attributeName <<
" failed";
186 throw std::runtime_error(oss.str());
200 writeInt(
const std::string& attributeName,
int value)
const 204 std::ostringstream oss;
205 oss <<
"IIO writeInt for attibute " << attributeName <<
" failed";
206 throw std::runtime_error(oss.str());
219 writeFloat(
const std::string& attributeName,
float value)
const 223 std::ostringstream oss;
224 oss <<
"IIO writeFloat for attibute " << attributeName <<
" failed";
225 throw std::runtime_error(oss.str());
241 throw std::runtime_error(
"registerEventHandler failed");
254 &channel2, &different);
261 eventData.
diff = different;
~Iio()
Definition: iio.hpp:130
mraa_result_t mraa_iio_read_int(mraa_iio_context dev, const char *filename, int *data)
Iio(int device)
Definition: iio.hpp:82
int mraa_iio_get_device_num_by_name(const char *name)
virtual void onIioEvent(const IioEventData &eventData)=0
int type
Definition: iio.hpp:42
mraa_result_t mraa_iio_close(mraa_iio_context dev)
int channelType
Definition: iio.hpp:38
mraa_result_t mraa_iio_write_float(mraa_iio_context dev, const char *attr_chan, const float data)
std::string getDeviceName() const
Definition: iio.hpp:142
int readInt(const std::string &attributeName) const
Definition: iio.hpp:157
API to Industrial IO.
Definition: iio.hpp:71
Iio(const std::string &deviceName)
Definition: iio.hpp:99
const char * mraa_iio_get_device_name(mraa_iio_context dev)
void registerEventHandler(IioHandler *handler) const
Definition: iio.hpp:237
float readFloat(const std::string &attributeName) const
Definition: iio.hpp:179
mraa_result_t mraa_iio_read_float(mraa_iio_context dev, const char *filename, float *data)
mraa_result_t mraa_iio_event_setup_callback(mraa_iio_context dev, void(*fptr)(struct iio_event_data *data, void *args), void *args)
int modifier
Definition: iio.hpp:40
Iio(void *iio_context)
Definition: iio.hpp:119
mraa_iio_context mraa_iio_init(int device)
void writeFloat(const std::string &attributeName, float value) const
Definition: iio.hpp:219
mraa_result_t mraa_iio_event_extract_event(struct iio_event_data *event, int *chan_type, int *modifier, int *type, int *direction, int *channel, int *channel2, int *different)
int channel
Definition: iio.hpp:46
int channel2
Definition: iio.hpp:48
struct _iio * mraa_iio_context
Definition: iio.h:87
mraa_result_t mraa_iio_write_int(mraa_iio_context dev, const char *attr_chan, const int data)
int diff
Definition: iio.hpp:50
mraa_result_t
Definition: types.h:209
void writeInt(const std::string &attributeName, int value) const
Definition: iio.hpp:200
Definition: iio_kernel_headers.h:119
virtual ~IioHandler()
Definition: iio.hpp:60
int direction
Definition: iio.hpp:44