You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update documentation across the tree to reflect the buffer_stream API
changes. Add missing doxygen comments for new public functions in the
header file, update the Python bindings documentation and the test
README.
In mainpage.dox, beyond updating to the new buffer_stream/block API,
also fix references to legacy v0.x APIs (such as iio_buffer_refill,
iio_buffer_push, iio_buffer_foreach_sample, iio_buffer_first/step/end)
that were already gone but still documented.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Copy file name to clipboardExpand all lines: mainpage.dox
+78-36Lines changed: 78 additions & 36 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Separately, the IIO Library also includes a set of test examples and utilities,
16
16
The full terms of the library license can be found at: http://opensource.org/licenses/LGPL-2.1 and the iio-utils license can be found at: https://opensource.org/licenses/GPL-2.0
17
17
18
18
@section code_model Code Model
19
-
The basic bricks of the libiio API are the iio_context, iio_device, iio_channeland iio_buffer classes.
19
+
The basic bricks of the libiio API are the iio_context, iio_device, iio_channel, iio_buffer, iio_buffer_stream and iio_block classes.
20
20
21
21

22
22
@@ -133,44 +133,83 @@ To see if one device is associated with a trigger, use iio_device_get_trigger().
133
133
To assign one trigger to a iio_device, you can use iio_device_set_trigger(). If you want to disassociate a iio_device from its trigger, pass NULL to the "trigger" parameter of this function.
134
134
135
135
@section capture_upload Capturing or uploading samples
136
-
The process of capturing samples from the hardware and uploading samples to the hardware is done using the functions that apply to the iio_buffer object.
136
+
The process of capturing samples from the hardware and uploading samples to the hardware is done using the iio_buffer, iio_buffer_stream and iio_block objects.
137
137
138
-
@subsection create_buffer Enabling channels and creating the Buffer object
138
+
@subsection create_buffer Enabling channels and opening a Buffer stream
139
139
The very first step is to enable the capture channels that we want to use, and disable those that we don't need.
140
-
This is done with the functions iio_channel_enable() and iio_channel_disable().
141
-
Note that the channels will really be enabled or disabled when the iio_buffer object is created.
140
+
This is done by creating an iio_channels_mask with iio_create_channels_mask() and then calling iio_channel_enable() for the desired channels.
142
141
143
142
Also, not all channels can be enabled. To know whether or not one channel can be enabled, use iio_channel_is_scan_element().
144
143
145
-
Once the channels have been enabled, and triggers assigned (for triggered buffers) the iio_buffer object can be created from the iio_device object that will be used, with the function iio_device_create_buffer().
146
-
This call will fail if no channels have been enabled, or for triggered buffers, if the trigger has not been assigned.
144
+
Buffers are pre-created during device context creation. To obtain a buffer, use iio_device_get_buffer(). To open it for streaming, call iio_buffer_open() with the channels mask, which returns an iio_buffer_stream object.
145
+
This call will fail if no channels have been enabled in the mask, or for triggered buffers, if the trigger has not been assigned.
147
146
148
-
When the object is no more needed, it can be destroyed with iio_buffer_destroy().
147
+
When the stream is no longer needed, it can be closed with iio_buffer_close().
149
148
150
-
@subsection refill Refilling the Buffer (input devices only)
151
-
If the Buffer object has been created from a device with input channels, then it must be updated first. This is done with the iio_buffer_refill() function.
149
+
@subsection streaming Streaming with blocks
150
+
Data is transferred to and from the hardware using iio_block objects. There are two approaches: manual block management or the high-level iio_stream API.
152
151
153
-
@subsection read_write Reading or writing samples to the Buffer
154
-
Libiio offers various ways to interact with the iio_buffer object.
Create one or more blocks from the buffer stream with iio_buffer_stream_create_block(). Each block represents a contiguous region of memory for sample data.
154
+
155
+
To start data flow, call iio_buffer_stream_start(). Then use iio_block_enqueue() to submit a block for I/O, and iio_block_dequeue() to wait for the transfer to complete. To stop, call iio_buffer_stream_stop() or iio_buffer_stream_cancel().
/* Process samples via iio_block_start()/iio_block_end() */
169
+
}
170
+
171
+
iio_block_destroy(block);
172
+
iio_buffer_close(stream);
173
+
~~~
174
+
175
+
@subsubsection stream_api High-level Stream API
176
+
The iio_stream API simplifies streaming by managing blocks internally. Create a stream with iio_buffer_create_stream(), specifying the number of blocks and the number of samples per block. Then iterate by calling iio_stream_get_next_block() in a loop.
/* Process samples via iio_block_start()/iio_block_end() */
185
+
}
186
+
187
+
iio_stream_destroy(stream);
188
+
~~~
189
+
190
+
To abort a running stream from another thread or signal context, use iio_stream_cancel(). Destroying the stream with iio_stream_destroy() will also close the underlying buffer stream.
191
+
192
+
@subsection read_write Reading or writing samples to a Block
193
+
Libiio offers various ways to interact with the iio_block object.
155
194
156
195
@subsubsection memcpy Direct copy
157
196
If you already have a buffer of samples, correctly interleaved and in the format that the hardware expects,
158
-
it is possible to copy the samples directly into the iio_buffer object using `memcpy`:
197
+
it is possible to copy the samples directly into the iio_block object using `memcpy`:
0 commit comments