no-OS
iiod_private.h
Go to the documentation of this file.
1 /***************************************************************************/
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 */
51 struct 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  */
60 enum iiod_cmd {
75 };
76 
77 /*
78  * Structure to be filled after a command is parsed.
79  * Depending of cmd some fields are set or not
80  */
81 struct comand_desc {
82  enum iiod_cmd cmd;
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 */
97 struct 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 */
107  bool write_val;
108  /* If buf.len != 0 buf has to be sent */
109  struct iiod_buff buf;
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 */
139  } state;
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).*/
146  char *payload_buf;
147  /* Length of payload_buf_len */
148  uint32_t 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 */
157  char *strtok_ctx;
158  /* True if the device was open with cyclic buffer flag */
160 };
161 
162 /* Private iiod information */
163 struct 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
comand_desc::trigger
char trigger[MAX_TRIG_ID]
Definition: iiod_private.h:92
iiod_desc::app_instance
void * app_instance
Definition: iiod_private.h:169
iiod_conn_priv::IIOD_LINE_DONE
@ IIOD_LINE_DONE
Definition: iiod_private.h:136
iiod_desc::phy_type
enum physical_link_type phy_type
Definition: iiod_private.h:175
IIOD_CMD_EXIT
@ IIOD_CMD_EXIT
Definition: iiod_private.h:62
iiod_conn_priv::used
bool used
Definition: iiod_private.h:117
comand_desc::timeout
uint32_t timeout
Definition: iiod_private.h:84
iiod_buff
Definition: iiod_private.h:97
iiod_conn_priv::conn
void * conn
Definition: iiod_private.h:115
IIOD_CMD_OPEN
@ IIOD_CMD_OPEN
Definition: iiod_private.h:66
MAX_TRIG_ID
#define MAX_TRIG_ID
Definition: iiod.h:48
IIOD_CMD_SET
@ IIOD_CMD_SET
Definition: iiod_private.h:74
iiod_conn_priv::buf_mask
char buf_mask[10]
Definition: iiod_private.h:155
iiod_desc
Definition: iiod_private.h:163
iiod_conn_priv::IIOD_READING_WRITE_DATA
@ IIOD_READING_WRITE_DATA
Definition: iiod_private.h:134
iiod_str::str
char * str
Definition: iiod_private.h:52
iiod_run_cmd_result::write_val
bool write_val
Definition: iiod_private.h:107
iiod_str
Definition: iiod_private.h:51
device
Definition: ad9361_util.h:69
iiod_conn_priv::parser_buf
char parser_buf[IIOD_PARSER_MAX_BUF_SIZE]
Definition: iiod_private.h:142
iiod_desc::xml_len
uint32_t xml_len
Definition: iiod_private.h:173
iiod_desc::xml
char * xml
Definition: iiod_private.h:171
iio_attr_type
iio_attr_type
Definition: iiod.h:52
IIOD_CMD_READ
@ IIOD_CMD_READ
Definition: iiod_private.h:68
iiod_conn_priv::payload_buf
char * payload_buf
Definition: iiod_private.h:146
IIOD_CMD_WRITEBUF
@ IIOD_CMD_WRITEBUF
Definition: iiod_private.h:71
iiod_str::len
uint32_t len
Definition: iiod_private.h:53
iiod_buff::idx
uint32_t idx
Definition: iiod_private.h:99
iiod_conn_priv
Definition: iiod_private.h:113
iio.h
Header file of iio.
IIOD_MAX_CONNECTIONS
#define IIOD_MAX_CONNECTIONS
Definition: iiod.h:43
comand_desc::type
enum iio_attr_type type
Definition: iiod_private.h:93
iiod_conn_priv::state
enum iiod_conn_priv::@2 state
comand_desc::mask
uint32_t mask
Definition: iiod_private.h:83
iiod_conn_priv::IIOD_RW_BUF
@ IIOD_RW_BUF
Definition: iiod_private.h:132
iiod_conn_priv::mask
uint32_t mask
Definition: iiod_private.h:153
IIOD_CMD_PRINT
@ IIOD_CMD_PRINT
Definition: iiod_private.h:63
comand_desc::cyclic
bool cyclic
Definition: iiod_private.h:88
iiod_desc::conns
struct iiod_conn_priv conns[IIOD_MAX_CONNECTIONS]
Definition: iiod_private.h:165
comand_desc::cmd
enum iiod_cmd cmd
Definition: iiod_private.h:82
iiod_buff::buf
char * buf
Definition: iiod_private.h:98
IIOD_PARSER_MAX_BUF_SIZE
#define IIOD_PARSER_MAX_BUF_SIZE
Definition: iiod_private.h:42
iiod_conn_priv::nb_buf
struct iiod_buff nb_buf
Definition: iiod_private.h:150
comand_desc::count
uint32_t count
Definition: iiod_private.h:87
iiod_desc::ops
struct iiod_ops ops
Definition: iiod_private.h:167
comand_desc::attr
char attr[MAX_ATTR_NAME]
Definition: iiod_private.h:91
iiod_conn_priv::IIOD_READING_LINE
@ IIOD_READING_LINE
Definition: iiod_private.h:126
iiod_conn_priv::cmd_data
struct comand_desc cmd_data
Definition: iiod_private.h:120
MAX_DEV_ID
#define MAX_DEV_ID
Definition: iiod.h:47
IIOD_CMD_CLOSE
@ IIOD_CMD_CLOSE
Definition: iiod_private.h:67
MAX_CHN_ID
#define MAX_CHN_ID
Definition: iiod.h:49
IIOD_CMD_GETTRIG
@ IIOD_CMD_GETTRIG
Definition: iiod_private.h:72
iiod_run_cmd_result::buf
struct iiod_buff buf
Definition: iiod_private.h:109
iiod_conn_priv::IIOD_WRITING_CMD_RESULT
@ IIOD_WRITING_CMD_RESULT
Definition: iiod_private.h:130
comand_desc::sample_count
uint32_t sample_count
Definition: iiod_private.h:85
IIOD_CMD_WRITE
@ IIOD_CMD_WRITE
Definition: iiod_private.h:69
iiod_conn_priv::IIOD_RUNNING_CMD
@ IIOD_RUNNING_CMD
Definition: iiod_private.h:128
iiod_conn_priv::payload_buf_len
uint32_t payload_buf_len
Definition: iiod_private.h:148
comand_desc::bytes_count
uint32_t bytes_count
Definition: iiod_private.h:86
iiod_buff::len
uint32_t len
Definition: iiod_private.h:100
iiod_run_cmd_result
Definition: iiod_private.h:104
MAX_ATTR_NAME
#define MAX_ATTR_NAME
Definition: iiod.h:50
iiod_conn_priv::strtok_ctx
char * strtok_ctx
Definition: iiod_private.h:157
iiod_ops
Definition: iiod.h:88
IIOD_CMD_SETTRIG
@ IIOD_CMD_SETTRIG
Definition: iiod_private.h:73
IIOD_CMD_HELP
@ IIOD_CMD_HELP
Definition: iiod_private.h:61
comand_desc::channel
char channel[MAX_CHN_ID]
Definition: iiod_private.h:90
iiod_conn_priv::res
struct iiod_run_cmd_result res
Definition: iiod_private.h:122
iiod_conn_priv::IIOD_PUSH_CYCLIC_BUFFER
@ IIOD_PUSH_CYCLIC_BUFFER
Definition: iiod_private.h:138
IIOD_CMD_READBUF
@ IIOD_CMD_READBUF
Definition: iiod_private.h:70
IIOD_CMD_TIMEOUT
@ IIOD_CMD_TIMEOUT
Definition: iiod_private.h:65
IIOD_CMD_VERSION
@ IIOD_CMD_VERSION
Definition: iiod_private.h:64
iiod_conn_priv::parser_idx
uint32_t parser_idx
Definition: iiod_private.h:144
iiod_conn_priv::is_cyclic_buffer
bool is_cyclic_buffer
Definition: iiod_private.h:159
physical_link_type
physical_link_type
Definition: iio.h:52
iiod_cmd
iiod_cmd
Definition: iiod_private.h:60
iiod_run_cmd_result::val
uint32_t val
Definition: iiod_private.h:105
comand_desc
Definition: iiod_private.h:81