2 Function: comedi_cancel -- stop streaming input/output in progress
4 Param: comedi_t * device
5 Param: unsigned int subdevice
7 The function comedi_cancel() can be used to stop a command
9 <link linkend="func-ref-comedi-command"><function>comedi_command</function></link>
10 which is still in progress
11 on the subdevice indicated by the parameters <parameter>device</parameter>
12 and <parameter>subdevice</parameter>.
14 If successful, 0 is returned, otherwise -1.
16 Function: comedi_command -- start streaming input/output
18 Param: comedi_t * device
19 Param: comedi_cmd * command
21 The function comedi_command() starts a streaming input
23 command structure *<parameter>command</parameter> specifies
25 acquisition. The command must be able to pass
26 <link linkend="func-ref-comedi-command-test"><function>comedi_command_test</function></link>
27 with a return value of 0, or comedi_command() will fail.
28 For input subdevices, sample values are read using the
29 function read() on the device file. For output subdevices, sample values are written
30 using the function write().
32 If successful, 0 is returned, otherwise -1.
34 Function: comedi_command_test -- test streaming input/output configuration
36 Param: comedi_t * device
37 Param: comedi_cmd * command
39 The function comedi_command_test() tests the command structure pointed
40 to by the parameter <parameter>command</parameter> and returns an
41 integer describing the
42 testing stages that were successfully passed. In addition, if elements
43 of the *<parameter>command</parameter> structure are invalid, they may be modified. Source
44 elements are modified to remove invalid source triggers. Argument
45 elements are adjusted or rounded to the nearest valid value.
47 The meanings of the return value are as follows:
51 <para>0 indicates a valid command.</para>
55 1 indicates that one of the *_src
56 members of the command contained an
57 unsupported trigger. The bits corresponding to the unsupported
63 2 indicates that the particular combination
64 of *_src settings is not supported by the driver, or that
65 one of the *_src members has the bit corresponding to
66 multiple trigger sources set at the same time.
71 3 indicates that one of the *_arg members
72 of the command is set outside the range of allowable values.
73 For instance, an argument for a TRIG_TIMER source which
74 exceeds the board's maximum speed. The invalid *_arg
75 members will be adjusted to valid values.
80 4 indicates that one of the *_arg members
81 required adjustment. For instance, the argument of a
82 TRIG_TIMER source may have been rounded to the nearest
83 timing period supported by the board.
88 5 indicates that some aspect of the
89 command's chanlist is unsupported by the board. For example,
90 some analog input boards require that all channels in the chanlist
91 use the same input range.
96 Function: comedi_get_buffer_contents -- streaming buffer status
98 Param: comedi_t * device
99 Param: unsigned int subdevice
101 The function comedi_get_buffer_contents() is used on a subdevice
102 that has a Comedi command in progress. The number of bytes that
103 are available in the streaming buffer is returned. If there is
104 an error, -1 is returned.
106 Function: comedi_get_buffer_offset -- streaming buffer status
108 Param: comedi_t * device
109 Param: unsigned int subdevice
111 The function comedi_get_buffer_offset() is used on a subdevice
112 that has a Comedi command in progress. This function returns
113 the offset in bytes of the read pointer in the streaming buffer.
114 This offset is only useful for memory mapped buffers.
115 If there is an error, -1 is returned.
117 Function: comedi_get_buffer_size -- streaming buffer size of subdevice
119 Param: comedi_t * device
120 Param: unsigned int subdevice
122 The function comedi_get_buffer_size() returns the size (in bytes)
123 of the streaming buffer for the subdevice specified by
124 <parameter>device</parameter> and
125 <parameter>subdevice</parameter>. On error, -1 is returned.
127 Function: comedi_get_cmd_generic_timed -- streaming input/output capabilities
129 Param: comedi_t * device
130 Param: unsigned int subdevice
131 Param: comedi_cmd * command
132 Param: unsigned int chanlist_len
133 Param: unsigned int scan_period_ns
135 The command capabilities of the subdevice indicated by the parameters
136 <parameter>device</parameter> and <parameter>subdevice</parameter>
137 are probed, and the results placed in the
138 command structure pointed to by the parameter command. The command
139 structure *<parameter>command</parameter> is modified to be a
140 valid command that can be used as a parameter to
141 <link linkend="func-ref-comedi-command"><function>comedi_command</function></link>
142 (after the command has additionally been assigned a valid chanlist array).
143 The command measures scans consisting of <parameter>chanlist_len</parameter>
145 at a scan rate that corresponds to a period of
146 <parameter>scan_period_ns</parameter> nanoseconds.
147 The rate is adjusted to a rate that the device
150 If successful, 0 is returned, otherwise -1.
152 Function: comedi_get_cmd_src_mask -- streaming input/output capabilities
154 Param: comedi_t * device
155 Param: unsigned int subdevice
156 Param: comedi_cmd * command
158 The command capabilities of the subdevice indicated by the parameters
159 <parameter>device</parameter> and <parameter>subdevice</parameter>
160 are probed, and the results placed in the
161 command structure *<parameter>command</parameter>. The trigger
162 source elements of the command structure are set to be the bitwise-or
163 of the subdevice's supported trigger sources. Other elements in the structure
166 If successful, 0 is returned, otherwise -1.
168 Function: comedi_get_max_buffer_size -- maximum streaming buffer size
170 Param: comedi_t * device
171 Param: unsigned int subdevice
173 The function comedi_get_max_buffer_size() returns the maximum
174 allowable size (in bytes) of the streaming buffer for the subdevice
175 specified by <parameter>device</parameter> and <parameter>subdevice</parameter>.
176 Changing the maximum buffer
177 size can be accomplished with
178 <link linkend="func-ref-comedi-set-max-buffer-size"><function>comedi_set_max_buffer_size</function></link>
179 or with the comedi_config program,
180 and requires appropriate privileges. On error, -1 is returned.
182 Function: comedi_get_read_subdevice -- find streaming input subdevice
184 Param: comedi_t * device
186 The function comedi_get_read_subdevice() returns the subdevice
187 whose streaming input buffer is accessible through the
188 device <parameter>dev</parameter>. If
189 there is no such subdevice, -1 is returned.
191 Function: comedi_get_write_subdevice -- find streaming output subdevice
193 Param: comedi_t * device
195 The function comedi_get_write_subdevice() returns the subdevice
196 whose streaming output buffer is accessible through the
197 device <parameter>dev</parameter>. If there is no such subdevice,
200 Function: comedi_mark_buffer_read -- streaming buffer control
202 Param: comedi_t * device
203 Param: unsigned int subdevice
204 Param: unsigned int num_bytes
206 The function comedi_mark_buffer_read() is used on a subdevice
207 that has a Comedi input command in progress. It should only be used
208 if you are using a mmap() to read data from Comedi's buffer
209 (as opposed to calling read() on the device file),
210 since Comedi will automatically keep track of how many bytes have been
211 transferred via read() calls. This function is
212 used to indicate that the next <parameter>num_bytes</parameter>
214 are no longer needed and may be discarded.
216 The function <function>comedi_mark_buffer_read</function> returns the
217 number of bytes successfully marked as read,
218 or -1 on error. The return value may be less than
219 <parameter>num_bytes</parameter> if you attempt to mark more
220 bytes read than are currently available for reading, or
221 if <parameter>num_bytes</parameter> must be rounded down
222 to be an exact multiple of the subdevice's
223 sample size (either sizeof(sampl_t) or sizeof(lsampl_t)).
225 Function: comedi_mark_buffer_written -- streaming buffer control
227 Param: comedi_t * device
228 Param: unsigned int subdevice
229 Param: unsigned int num_bytes
231 The function comedi_mark_buffer_written() is used on a subdevice
232 that has a Comedi output command in progress. It should only be used
233 if you are using a mmap() to write data to Comedi's buffer
234 (as opposed to calling write() on the device
236 will automatically keep track of how many bytes have been
237 transferred via write() calls. This function is
238 used to indicate that the next <parameter>num_bytes</parameter>
240 are valid and may be sent to the device.
242 The function <function>comedi_mark_buffer_written</function> returns
243 number of bytes successfully marked as written,
244 or -1 on error. The return value may be less than
245 <parameter>num_bytes</parameter> if you attempt to mark more
246 bytes written than the amount of free space currently available
247 in the output buffer, or
248 if <parameter>num_bytes</parameter> must be
249 rounded down to be an exact multiple of the subdevice's
250 sample size (either sizeof(sampl_t) or sizeof(lsampl_t)).
252 Function: comedi_poll -- force updating of streaming buffer
254 Param: comedi_t * device
255 Param: unsigned int subdevice
257 The function comedi_poll() is used on a subdevice that has a
258 Comedi command in progress in order to update the streaming buffer.
259 If supported by the driver, all available samples are copied to
260 the streaming buffer. These samples may be pending in DMA buffers
261 or device FIFOs. If successful, the number of additional bytes
262 available is returned. If there is an error, -1 is returned.
264 Function: comedi_set_buffer_size -- streaming buffer size of subdevice
266 Param: comedi_t * device
267 Param: unsigned int subdevice
268 Param: unsigned int size
270 The function comedi_set_buffer_size() changes the size of the
271 streaming buffer for the subdevice specified by
272 <parameter>device</parameter> and <parameter>subdevice</parameter>.
273 The buffer size will be set to <parameter>size</parameter> bytes,
274 rounded up to a multiple of the virtual memory page
275 size. The virtual memory page size can be determined using
276 sysconf(_SC_PAGE_SIZE).
278 This function does not require special privileges. However,
279 it is limited to a (adjustable) maximum buffer size, which can
280 be changed by a priveliged user calling
281 <link linkend="func-ref-comedi-set-max-buffer-size"><function>comedi_set_max_buffer_size</function></link>,
282 or running the program comedi_config.
284 The new buffer size in bytes is returned on success. On error,
287 Function: comedi_set_max_buffer_size -- streaming buffer size of subdevice
289 Param: comedi_t * device
290 Param: unsigned int subdevice
291 Param: unsigned int max_size
293 The function comedi_set_max_buffer_size() changes the maximum
294 allowable size (in bytes) of the streaming buffer for the subdevice
295 specified by device and subdevice. Changing the maximum buffer
296 size requires the user to have appropriate privileges.
298 The old buffer size is returned on success. On error, -1 is returned.