2 Function: comedi_cancel -- stop streaming input/output in progress
4 Param: comedi_t * device
5 Param: unsigned int subdevice
7 The function <function>comedi_cancel</function> can be used to stop a command
9 <function><link linkend="func-ref-comedi-command">comedi_command</link></function>
10 which is still in progress
11 on the subdevice indicated by the parameters <parameter class="function">device</parameter>
12 and <parameter class="function">subdevice</parameter>.
14 If successful, <literal>0</literal> is returned, otherwise
15 <literal>-1</literal>.
17 Function: comedi_command -- start streaming input/output
19 Param: comedi_t * device
20 Param: comedi_cmd * command
22 The function <function>comedi_command</function> starts a streaming input
24 command structure pointed to by <parameter class="function">command</parameter> specifies
26 acquisition. The command must be able to pass
28 linkend="func-ref-comedi-command-test">comedi_command_test</link></function>
29 with a return value of <literal>0</literal>, or
30 <function>comedi_command</function> will fail.
31 For input subdevices, sample values are read using the
32 function <function>read</function> on the device file. For output subdevices,
33 sample values are written using the function <function>write</function>.
35 If successful, <literal>0</literal> is returned, otherwise
36 <literal>-1</literal>.
38 Function: comedi_command_test -- test streaming input/output configuration
40 Param: comedi_t * device
41 Param: comedi_cmd * command
43 The function <function>comedi_command_test</function> tests the command structure pointed
44 to by the parameter <parameter class="function">command</parameter> and returns an
45 integer describing the
46 testing stages that were successfully passed. In addition, if elements
47 of the <type>comedi_cmd</type> structure are invalid, they may be modified. Source
48 elements are modified to remove invalid source triggers. Argument
49 elements are adjusted or rounded to the nearest valid value.
51 The meanings of the return value are as follows:
55 <para><literal>0</literal> indicates a valid command.</para>
59 <literal>1</literal> indicates that one of the
60 <structfield>…_src</structfield>
61 members of the command contained an
62 unsupported trigger. The bits corresponding to the unsupported
68 <literal>2</literal> indicates that the particular combination
69 of <structfield>…_src</structfield> settings is not supported by the driver, or that
70 one of the <structfield>…_src</structfield> members has the bit corresponding to
71 multiple trigger sources set at the same time.
76 <literal>3</literal> indicates that one of the
77 <structfield>…_arg</structfield> members
78 of the command is set outside the range of allowable values.
79 For instance, an argument for a
80 <constant>TRIG_TIMER</constant> source which
81 exceeds the board's maximum speed. The invalid
82 <structfield>…_arg</structfield>
83 members will be adjusted to valid values.
88 <literal>4</literal> indicates that one of the
89 <structfield>…_arg</structfield> members
90 required adjustment. For instance, the argument of a
91 <constant>TRIG_TIMER</constant> source may have been rounded to the nearest
92 timing period supported by the board.
97 <literal>5</literal> indicates that some aspect of the
98 command's <structfield>chanlist</structfield> is unsupported by the board. For example,
99 some analog input boards require that all channels in the chanlist
100 use the same input range.
105 Function: comedi_get_buffer_contents -- streaming buffer status
107 Param: comedi_t * device
108 Param: unsigned int subdevice
110 The function <function>comedi_get_buffer_contents</function> is used on a subdevice
111 that has a Comedi command in progress. The number of bytes that
112 are available in the streaming buffer is returned. If there is
113 an error, <literal>-1</literal> is returned.
115 Function: comedi_get_buffer_offset -- streaming buffer status
117 Param: comedi_t * device
118 Param: unsigned int subdevice
120 The function <function>comedi_get_buffer_offset</function> is used on a subdevice
121 that has a Comedi command in progress. This function returns
122 the offset in bytes of the read pointer in the streaming buffer.
123 This offset is only useful for memory mapped buffers.
124 If there is an error, <literal>-1</literal> is returned.
126 Function: comedi_get_buffer_size -- streaming buffer size of subdevice
128 Param: comedi_t * device
129 Param: unsigned int subdevice
131 The function <function>comedi_get_buffer_size</function> returns the size (in bytes)
132 of the streaming buffer for the subdevice specified by
133 <parameter class="function">device</parameter> and
134 <parameter class="function">subdevice</parameter>.
135 On error, <literal>-1</literal> is returned.
137 Function: comedi_get_cmd_generic_timed -- streaming input/output capabilities
139 Param: comedi_t * device
140 Param: unsigned int subdevice
141 Param: comedi_cmd * command
142 Param: unsigned int chanlist_len
143 Param: unsigned int scan_period_ns
145 The command capabilities of the subdevice indicated by the parameters
146 <parameter class="function">device</parameter> and <parameter
147 class="function">subdevice</parameter>
148 are probed, and the results placed in the
149 command structure pointed to by the parameter <parameter
150 class="function">command</parameter>.
151 The command structure pointed to by <parameter class="function">command</parameter>
153 valid command that can be used as a parameter to
154 <function><link linkend="func-ref-comedi-command">comedi_command</link></function>
155 (after the command has additionally been assigned a valid
156 <structfield>chanlist</structfield> array).
157 The command measures scans consisting of <parameter class="function">chanlist_len</parameter>
159 at a scan rate that corresponds to a period of
160 <parameter class="function">scan_period_ns</parameter> nanoseconds.
161 The rate is adjusted to a rate that the device
164 If successful, <literal>0</literal> is returned, otherwise
165 <literal>-1</literal>.
167 Function: comedi_get_cmd_src_mask -- streaming input/output capabilities
169 Param: comedi_t * device
170 Param: unsigned int subdevice
171 Param: comedi_cmd * command
173 The command capabilities of the subdevice indicated by the parameters
174 <parameter class="function">device</parameter> and <parameter
175 class="function">subdevice</parameter>
176 are probed, and the results placed in the
177 command structure pointed to by <parameter class="function">command</parameter>. The trigger
178 source elements of the command structure are set to be the bitwise-or
179 of the subdevice's supported trigger sources. Other elements in the structure
182 If successful, <literal>0</literal> is returned, otherwise
183 <literal>-1</literal>.
185 Function: comedi_get_max_buffer_size -- maximum streaming buffer size
187 Param: comedi_t * device
188 Param: unsigned int subdevice
190 The function <function>comedi_get_max_buffer_size</function> returns the maximum
191 allowable size (in bytes) of the streaming buffer for the subdevice
192 specified by <parameter class="function">device</parameter>
193 and <parameter class="function">subdevice</parameter>.
194 Changing the maximum buffer
195 size can be accomplished with
197 linkend="func-ref-comedi-set-max-buffer-size">comedi_set_max_buffer_size</link></function>
198 or with the <command>comedi_config</command> program,
199 and requires appropriate privileges. On error, <literal>-1</literal> is returned.
201 Function: comedi_get_read_subdevice -- find streaming input subdevice
203 Param: comedi_t * device
205 The function <function>comedi_get_read_subdevice</function> returns the
206 index of the subdevice
207 whose streaming input buffer is accessible through the
208 device <parameter class="function">device</parameter>. If
209 there is no such subdevice, <literal>-1</literal> is returned.
211 Function: comedi_get_write_subdevice -- find streaming output subdevice
213 Param: comedi_t * device
215 The function <function>comedi_get_write_subdevice</function> returns the
216 index of the subdevice
217 whose streaming output buffer is accessible through the
218 device <parameter class="device">device</parameter>. If there is no such subdevice,
219 <literal>-1</literal> is returned.
221 Function: comedi_mark_buffer_read -- streaming buffer control
223 Param: comedi_t * device
224 Param: unsigned int subdevice
225 Param: unsigned int num_bytes
227 The function <function>comedi_mark_buffer_read</function> is used on a subdevice
228 that has a Comedi input command in progress. It should only be used
229 if you are using a <function>mmap</function> mapping to read data from Comedi's buffer
230 (as opposed to calling <function>read</function> on the device file),
231 since Comedi will automatically keep track of how many bytes have been
232 transferred via <function>read</function> calls. This function is
233 used to indicate that the next <parameter class="function">num_bytes</parameter>
235 are no longer needed and may be discarded.
237 The function <function>comedi_mark_buffer_read</function> returns the
238 number of bytes successfully marked as read,
239 or <literal>-1</literal> on error. The return value may be less than
240 <parameter class="function">num_bytes</parameter> if you attempt to mark more
241 bytes read than are currently available for reading, or
242 if <parameter class="function">num_bytes</parameter> must be rounded down
243 to be an exact multiple of the subdevice's
244 sample size (either <code language="C">sizeof(sampl_t)</code> or
245 <code language="C">sizeof(lsampl_t)</code>).
247 Function: comedi_mark_buffer_written -- streaming buffer control
249 Param: comedi_t * device
250 Param: unsigned int subdevice
251 Param: unsigned int num_bytes
253 The function <function>comedi_mark_buffer_written</function> is used on a subdevice
254 that has a Comedi output command in progress. It should only be used
255 if you are using a <function>mmap</function> mapping to write data to Comedi's buffer
256 (as opposed to calling <function>write</function> on the device
258 will automatically keep track of how many bytes have been
259 transferred via <function>write</function> calls. This function is
260 used to indicate that the next <parameter class="function">num_bytes</parameter>
262 are valid and may be sent to the device.
264 The function <function>comedi_mark_buffer_written</function> returns
265 number of bytes successfully marked as written,
266 or <literal>-1</literal> on error. The return value may be less than
267 <parameter class="function">num_bytes</parameter> if you attempt to mark more
268 bytes written than the amount of free space currently available
269 in the output buffer, or
270 if <parameter class="function">num_bytes</parameter> must be
271 rounded down to be an exact multiple of the subdevice's
272 sample size (either <code language="C">sizeof(sampl_t)</code>
273 or <code language="C">sizeof(lsampl_t)</code>).
275 Function: comedi_poll -- force updating of streaming buffer
277 Param: comedi_t * device
278 Param: unsigned int subdevice
280 The function <function>comedi_poll</function> is used on a subdevice that has a
281 Comedi command in progress in order to update the streaming buffer.
282 If supported by the driver, all available samples are copied to
283 the streaming buffer. These samples may be pending in DMA buffers
284 or device FIFOs. If successful, the number of additional bytes
285 available is returned. If there is an error, <literal>-1</literal> is returned.
287 Function: comedi_set_buffer_size -- streaming buffer size of subdevice
289 Param: comedi_t * device
290 Param: unsigned int subdevice
291 Param: unsigned int size
293 The function <function>comedi_set_buffer_size</function> changes the size of the
294 streaming buffer for the subdevice specified by
295 <parameter class="function">device</parameter> and <parameter
296 class="function">subdevice</parameter>.
297 The buffer size will be set to <parameter class="function">size</parameter> bytes,
298 rounded up to a multiple of the virtual memory page
299 size. The virtual memory page size can be determined using
300 <code language="C">sysconf(_SC_PAGE_SIZE)</code>.
302 This function does not require special privileges. However,
303 it is limited to a (adjustable) maximum buffer size, which can
304 be changed by a privileged user calling
306 linkend="func-ref-comedi-set-max-buffer-size">comedi_set_max_buffer_size</link></function>,
307 or running the program <command>comedi_config</command>.
309 The new buffer size in bytes is returned on success. On error,
310 <literal>-1</literal> is returned.
312 Function: comedi_set_max_buffer_size -- streaming maximum buffer size of subdevice
314 Param: comedi_t * device
315 Param: unsigned int subdevice
316 Param: unsigned int max_size
318 The function <function>comedi_set_max_buffer_size</function> changes the maximum
319 allowable size (in bytes) of the streaming buffer for the subdevice
320 specified by <parameter class="function">device</parameter> and
321 <parameter class="function">subdevice</parameter>. Changing the maximum buffer
322 size requires the user to have appropriate privileges.
324 The new maximum buffer size is returned on success. On error, <literal>-1</literal> is returned.