no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
iiod_private.h
Go to the documentation of this file.
1/***************************************************************************/
33
34#ifndef IIOD_PRIVATE_H
35#define IIOD_PRIVATE_H
36
37#include "iio.h"
38
39#define IIOD_WR 0x1
40#define IIOD_ENDL 0x2
41#define IIOD_RD 0x4
42#define IIOD_PARSER_MAX_BUF_SIZE 128
43
44#define IIOD_STR(cmd) {(cmd), sizeof(cmd) - 1}
45
46#define IIOD_CTX(desc, conn) {.instance = (desc)->app_instance,\
47 .conn = (conn)->conn}
48
49
50/* Used to store a string and its size */
51struct iiod_str {
52 char *str;
53 uint32_t len;
54};
55
56/*
57 * Commads are the ones documented int the link:
58 * https://wiki.analog.com/resources/tools-software/linux-software/libiio_internals#the_network_backend_and_iio_daemon
59 */
76
77/*
78 * Structure to be filled after a command is parsed.
79 * Depending of cmd some fields are set or not
80 */
83 uint32_t mask;
84 uint32_t timeout;
85 uint32_t sample_count;
86 uint32_t bytes_count;
87 uint32_t count;
88 bool cyclic;
94};
95
96/* Used to store buffer indexes for non blocking transfers */
97struct iiod_buff {
98 char *buf;
99 uint32_t idx;
100 uint32_t len;
101};
102
103/* Result after executing a command. */
105 uint32_t val;
106 /* If set. Val needs to be sent */
108 /* If buf.len != 0 buf has to be sent */
110};
111
112/* Internal structure to handle a connection state */
114 /* User instance of the connection to be sent in iiod_ctx */
115 void *conn;
116 /* Unset when can be used from the connection pool */
117 bool used;
118
119 /* Command data after parsed */
121 /* Result of an executed cmd */
123 /* IIOD States */
124 enum {
125 /* Reading line until \n */
127 /* Execut cmd without I/O operations */
129 /* Write result of executed cmd */
131 /* I/O operations for READBUF and WRITEBUF cmds */
133 /* I/O operations for WRITE cmd */
135 /* Set when a operation is finalized */
137 /* Pushing cyclic buffer until IIO device is closed */
140
141 /* Buffer to store received line */
143 /* Index in parser_buf. For nonblocking operation */
144 uint32_t parser_idx;
145 /* Buffer to store raw data (attributes or buffer data).*/
147 /* Length of payload_buf_len */
149 /* Used in nonbloking transfers to save indexes */
151
152 /* Mask of current opened buffer */
153 uint32_t mask;
154 /* Buffer to store mask as a string */
155 char buf_mask[10];
156 /* Context for strtok_r function */
158 /* True if the device was open with cyclic buffer flag */
160};
161
162/* Private iiod information */
163struct iiod_desc {
164 /* Pool of iiod connections */
166 /* Application operations */
167 struct iiod_ops ops;
168 /* Application instance */
170 /* Address of xml */
171 char *xml;
172 /* XML length in bytes */
173 uint32_t xml_len;
174 /* Backend used by IIOD */
176};
177
178#endif //IIOD_PRIVATE_H
Header file of iio.
physical_link_type
Definition iio.h:44
#define MAX_ATTR_NAME
Definition iiod.h:50
#define MAX_CHN_ID
Definition iiod.h:49
#define MAX_DEV_ID
Definition iiod.h:47
iio_attr_type
Definition iiod.h:52
#define IIOD_MAX_CONNECTIONS
Definition iiod.h:43
#define MAX_TRIG_ID
Definition iiod.h:48
#define IIOD_PARSER_MAX_BUF_SIZE
Definition iiod_private.h:42
iiod_cmd
Definition iiod_private.h:60
@ IIOD_CMD_PRINT
Definition iiod_private.h:63
@ IIOD_CMD_SETTRIG
Definition iiod_private.h:73
@ IIOD_CMD_SET
Definition iiod_private.h:74
@ IIOD_CMD_WRITE
Definition iiod_private.h:69
@ IIOD_CMD_HELP
Definition iiod_private.h:61
@ IIOD_CMD_WRITEBUF
Definition iiod_private.h:71
@ IIOD_CMD_CLOSE
Definition iiod_private.h:67
@ IIOD_CMD_READ
Definition iiod_private.h:68
@ IIOD_CMD_GETTRIG
Definition iiod_private.h:72
@ IIOD_CMD_VERSION
Definition iiod_private.h:64
@ IIOD_CMD_EXIT
Definition iiod_private.h:62
@ IIOD_CMD_OPEN
Definition iiod_private.h:66
@ IIOD_CMD_READBUF
Definition iiod_private.h:70
@ IIOD_CMD_TIMEOUT
Definition iiod_private.h:65
Definition iiod_private.h:81
uint32_t bytes_count
Definition iiod_private.h:86
bool cyclic
Definition iiod_private.h:88
char trigger[MAX_TRIG_ID]
Definition iiod_private.h:92
uint32_t count
Definition iiod_private.h:87
uint32_t timeout
Definition iiod_private.h:84
char channel[MAX_CHN_ID]
Definition iiod_private.h:90
enum iio_attr_type type
Definition iiod_private.h:93
uint32_t mask
Definition iiod_private.h:83
char attr[MAX_ATTR_NAME]
Definition iiod_private.h:91
enum iiod_cmd cmd
Definition iiod_private.h:82
char device[MAX_DEV_ID]
Definition iiod_private.h:89
uint32_t sample_count
Definition iiod_private.h:85
Definition iiod_private.h:97
char * buf
Definition iiod_private.h:98
uint32_t idx
Definition iiod_private.h:99
uint32_t len
Definition iiod_private.h:100
Definition iiod_private.h:113
struct iiod_run_cmd_result res
Definition iiod_private.h:122
struct comand_desc cmd_data
Definition iiod_private.h:120
uint32_t parser_idx
Definition iiod_private.h:144
bool is_cyclic_buffer
Definition iiod_private.h:159
uint32_t mask
Definition iiod_private.h:153
bool used
Definition iiod_private.h:117
@ IIOD_WRITING_CMD_RESULT
Definition iiod_private.h:130
@ IIOD_RW_BUF
Definition iiod_private.h:132
@ IIOD_PUSH_CYCLIC_BUFFER
Definition iiod_private.h:138
@ IIOD_LINE_DONE
Definition iiod_private.h:136
@ IIOD_READING_LINE
Definition iiod_private.h:126
@ IIOD_RUNNING_CMD
Definition iiod_private.h:128
@ IIOD_READING_WRITE_DATA
Definition iiod_private.h:134
char * strtok_ctx
Definition iiod_private.h:157
enum iiod_conn_priv::@242111370177320325242050134074014251200030247017 state
char * payload_buf
Definition iiod_private.h:146
uint32_t payload_buf_len
Definition iiod_private.h:148
char parser_buf[IIOD_PARSER_MAX_BUF_SIZE]
Definition iiod_private.h:142
char buf_mask[10]
Definition iiod_private.h:155
void * conn
Definition iiod_private.h:115
struct iiod_buff nb_buf
Definition iiod_private.h:150
Definition iiod_private.h:163
struct iiod_ops ops
Definition iiod_private.h:167
struct iiod_conn_priv conns[IIOD_MAX_CONNECTIONS]
Definition iiod_private.h:165
char * xml
Definition iiod_private.h:171
void * app_instance
Definition iiod_private.h:169
uint32_t xml_len
Definition iiod_private.h:173
enum physical_link_type phy_type
Definition iiod_private.h:175
Definition iiod.h:88
Definition iiod_private.h:104
bool write_val
Definition iiod_private.h:107
uint32_t val
Definition iiod_private.h:105
struct iiod_buff buf
Definition iiod_private.h:109
Definition iiod_private.h:51
uint32_t len
Definition iiod_private.h:53
char * str
Definition iiod_private.h:52