libiio: iiod-client.h Source File

libiio 1.0 Library for interfacing with IIO devices

Loading...
Searching...
No Matches
iiod-client.h
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * libiio - Library for interfacing industrial I/O (IIO) devices
4 *
5 * Copyright (C) 2015 Analog Devices, Inc.
6 * Author: Paul Cercueil <paul.cercueil@analog.com>
7 */
8
9#ifndef _IIOD_CLIENT_H
10#define _IIOD_CLIENT_H
11
12#include <iio/iio-backend.h>
13
14#define __api __iio_api
15
16struct iiod_client;
17struct iiod_client_io;
18struct iiod_client_pdata;
19struct iio_event_stream_pdata;
20
21struct iiod_client_ops {
22 ssize_t (*write)(struct iiod_client_pdata *desc,
23 const char *src, size_t len, unsigned int timeout_ms);
24 ssize_t (*read)(struct iiod_client_pdata *desc,
25 char *dst, size_t len, unsigned int timeout_ms);
26 ssize_t (*read_line)(struct iiod_client_pdata *desc,
27 char *dst, size_t len, unsigned int timeout_ms);
28 void (*cancel)(struct iiod_client_pdata *desc);
29};
30
31__api void iiod_client_mutex_lock(struct iiod_client *client);
32__api void iiod_client_mutex_unlock(struct iiod_client *client);
33
34__api struct iiod_client *
35iiod_client_new(const struct iio_context_params *params,
36 struct iiod_client_pdata *desc,
37 const struct iiod_client_ops *ops);
38
39__api void iiod_client_destroy(struct iiod_client *client);
40
41__api bool iiod_client_uses_binary_interface(const struct iiod_client *client);
42
43__api const struct iio_device *
44iiod_client_get_trigger(struct iiod_client *client,
45 const struct iio_device *dev);
46
47__api int iiod_client_set_trigger(struct iiod_client *client,
48 const struct iio_device *dev,
49 const struct iio_device *trigger);
50
51__api int iiod_client_set_timeout(struct iiod_client *client,
52 unsigned int timeout);
53
54__api ssize_t iiod_client_attr_read(struct iiod_client *client,
55 const struct iio_attr *attr,
56 char *dest, size_t len);
57
58__api ssize_t iiod_client_attr_write(struct iiod_client *client,
59 const struct iio_attr *attr,
60 const char *src, size_t len);
61
62__api struct iio_context *
63iiod_client_create_context(struct iiod_client *client,
64 const struct iio_backend *backend,
65 const char *description,
66 const char **ctx_attrs,
67 const char **ctx_values,
68 unsigned int nb_ctx_attrs);
69
70__api struct iiod_client_buffer_pdata *
71iiod_client_open_buffer(struct iiod_client *client,
72 struct iiod_client *client_fb,
73 const struct iio_device *dev, unsigned int idx,
74 struct iio_channels_mask *mask);
75__api void iiod_client_close_buffer(struct iiod_client_buffer_pdata *pdata);
76__api int iiod_client_enable_buffer(struct iiod_client_buffer_pdata *pdata,
77 size_t nb_samples, bool enable, bool cyclic);
78
79__api struct iio_block_pdata *
80iiod_client_create_block(struct iiod_client_buffer_pdata *pdata,
81 size_t size, void **data);
82__api void iiod_client_free_block(struct iio_block_pdata *block);
83
84__api int iiod_client_enqueue_block(struct iio_block_pdata *block,
85 size_t bytes_used, bool cyclic);
86
87__api int iiod_client_dequeue_block(struct iio_block_pdata *block,
88 bool nonblock);
89
90__api ssize_t iiod_client_readbuf(struct iiod_client_buffer_pdata *pdata,
91 void *dst, size_t len);
92__api ssize_t iiod_client_writebuf(struct iiod_client_buffer_pdata *pdata,
93 const void *src, size_t len);
94
95__api struct iio_event_stream_pdata *
96iiod_client_open_event_stream(struct iiod_client *client,
97 const struct iio_device *dev);
98__api void iiod_client_close_event_stream(struct iio_event_stream_pdata *pdata);
99__api int iiod_client_read_event(struct iio_event_stream_pdata *pdata,
100 struct iio_event *out_event,
101 bool nonblock);
102
103__api int iiod_client_reg_read(struct iiod_client *client,
104 const struct iio_device *dev,
105 uint32_t address, uint32_t *value);
106__api int iiod_client_reg_write(struct iiod_client *client,
107 const struct iio_device *dev,
108 uint32_t address, uint32_t value);
109
110#undef __api
111
112#endif /* _IIOD_CLIENT_H */
iio_attr
Structure holding meta-data for an attribute.
Definition iio-backend.h:83
iio_context_params
IIO context creation information.
Definition iio.h:167
iio_context
Contains the representation of an IIO context.
iio_device
Represents a device in the IIO context.
iio_event
Represents a IIO event.
Definition iio.h:1474