libiio  0.18
Library for interfacing with IIO devices
iiod-client.h
1 /*
2  * libiio - Library for interfacing industrial I/O (IIO) devices
3  *
4  * Copyright (C) 2015 Analog Devices, Inc.
5  * Author: Paul Cercueil <paul.cercueil@analog.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  */
18 
19 #ifndef _IIOD_CLIENT_H
20 #define _IIOD_CLIENT_H
21 
22 #include "iio-private.h"
23 
24 struct iio_mutex;
25 struct iiod_client;
26 struct iio_context_pdata;
27 
28 struct iiod_client_ops {
29  ssize_t (*write)(struct iio_context_pdata *pdata,
30  void *desc, const char *src, size_t len);
31  ssize_t (*read)(struct iio_context_pdata *pdata,
32  void *desc, char *dst, size_t len);
33  ssize_t (*read_line)(struct iio_context_pdata *pdata,
34  void *desc, char *dst, size_t len);
35 };
36 
37 struct iiod_client * iiod_client_new(struct iio_context_pdata *pdata,
38  struct iio_mutex *lock, const struct iiod_client_ops *ops);
39 void iiod_client_destroy(struct iiod_client *client);
40 
41 int iiod_client_get_version(struct iiod_client *client, void *desc,
42  unsigned int *major, unsigned int *minor, char *git_tag);
43 int iiod_client_get_trigger(struct iiod_client *client, void *desc,
44  const struct iio_device *dev,
45  const struct iio_device **trigger);
46 int iiod_client_set_trigger(struct iiod_client *client, void *desc,
47  const struct iio_device *dev, const struct iio_device *trigger);
48 int iiod_client_set_kernel_buffers_count(struct iiod_client *client,
49  void *desc, const struct iio_device *dev, unsigned int nb_blocks);
50 int iiod_client_set_timeout(struct iiod_client *client,
51  void *desc, unsigned int timeout);
52 ssize_t iiod_client_read_attr(struct iiod_client *client, void *desc,
53  const struct iio_device *dev, const struct iio_channel *chn,
54  const char *attr, char *dest, size_t len, enum iio_attr_type type);
55 ssize_t iiod_client_write_attr(struct iiod_client *client, void *desc,
56  const struct iio_device *dev, const struct iio_channel *chn,
57  const char *attr, const char *src, size_t len, enum iio_attr_type type);
58 int iiod_client_open_unlocked(struct iiod_client *client, void *desc,
59  const struct iio_device *dev, size_t samples_count,
60  bool cyclic);
61 int iiod_client_close_unlocked(struct iiod_client *client, void *desc,
62  const struct iio_device *dev);
63 ssize_t iiod_client_read_unlocked(struct iiod_client *client, void *desc,
64  const struct iio_device *dev, void *dst, size_t len,
65  uint32_t *mask, size_t words);
66 ssize_t iiod_client_write_unlocked(struct iiod_client *client, void *desc,
67  const struct iio_device *dev, const void *src, size_t len);
68 struct iio_context * iiod_client_create_context(
69  struct iiod_client *client, void *desc);
70 
71 #endif /* _IIOD_CLIENT_H */
iio_device_get_channels_count
unsigned int iio_device_get_channels_count(const struct iio_device *dev)
Enumerate the channels of the given device.
Definition: device.c:235
iio_channel
Represents an input or output channel of a device.
iio_device_find_buffer_attr
const char * iio_device_find_buffer_attr(const struct iio_device *dev, const char *name)
Try to find a buffer-specific attribute by its name.
Definition: device.c:305
iio_device_find_attr
const char * iio_device_find_attr(const struct iio_device *dev, const char *name)
Try to find a device-specific attribute by its name.
Definition: device.c:279
iio_device_get_name
const char * iio_device_get_name(const struct iio_device *dev)
Retrieve the device name (e.g. xadc)
Definition: device.c:230
iio_channel_is_output
bool iio_channel_is_output(const struct iio_channel *chn)
Return True if the given channel is an output channel.
Definition: channel.c:305
iio_context_get_device
struct iio_device * iio_context_get_device(const struct iio_context *ctx, unsigned int index)
Get the device present at the given index.
Definition: context.c:181
iio_create_xml_context_mem
struct iio_context * iio_create_xml_context_mem(const char *xml, size_t len)
Create a context from XML data in memory.
Definition: context.c:353
iio_context_get_devices_count
unsigned int iio_context_get_devices_count(const struct iio_context *ctx)
Enumerate the devices found in the given context.
Definition: context.c:176
iio_device_get_context
const struct iio_context * iio_device_get_context(const struct iio_device *dev)
Retrieve a pointer to the iio_context structure.
Definition: device.c:1148
iio_channel_find_attr
const char * iio_channel_find_attr(const struct iio_channel *chn, const char *name)
Try to find a channel-specific attribute by its name.
Definition: channel.c:339
iio_device_get_id
const char * iio_device_get_id(const struct iio_device *dev)
Retrieve the device ID (e.g. iio:device0)
Definition: device.c:225
iio_context
Contains the representation of an IIO context.
iio_device
Represents a device in the IIO context.
iio_device_is_trigger
bool iio_device_is_trigger(const struct iio_device *dev)
Return True if the given device is a trigger.
Definition: device.c:463
iio_channel_get_id
const char * iio_channel_get_id(const struct iio_channel *chn)
Retrieve the channel ID (e.g. voltage0)
Definition: channel.c:295
iio_device_find_debug_attr
const char * iio_device_find_debug_attr(const struct iio_device *dev, const char *name)
Try to find a debug attribute by its name.
Definition: device.c:317