1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>5.3. Data types and structures</title><link rel="stylesheet" type="text/css" href="comedilib.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><link rel="home" href="index.html" title="Comedi"><link rel="up" href="comedireference.html" title="5. Comedi reference"><link rel="prev" href="constantsmacros.html" title="5.2. Constants and macros"><link rel="next" href="functionreference.html" title="5.4. Functions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.3.
Data types and structures
</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="constantsmacros.html">Prev</a> </td><th width="60%" align="center">5.
<acronym class="acronym">Comedi</acronym> reference
</th><td width="20%" align="right"> <a accesskey="n" href="functionreference.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="datatypesstructures"></a>5.3.
Data types and structures
</h3></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="datatypesstructures.html#ref-type-comedi-devinfo">5.3.1.
comedi_devinfo
</a></span></dt><dt><span class="section"><a href="datatypesstructures.html#ref-type-comedi-t">5.3.2.
comedi_t
</a></span></dt><dt><span class="section"><a href="datatypesstructures.html#ref-type-sampl-t">5.3.3.
sampl_t
</a></span></dt><dt><span class="section"><a href="datatypesstructures.html#ref-type-lsampl-t">5.3.4.
lsampl_t
</a></span></dt><dt><span class="section"><a href="datatypesstructures.html#ref-type-comedi-trig">5.3.5.
comedi_trig (deprecated)
</a></span></dt><dt><span class="section"><a href="datatypesstructures.html#ref-type-comedi-sv-t">5.3.6.
comedi_sv_t (deprecated)
</a></span></dt><dt><span class="section"><a href="datatypesstructures.html#ref-type-comedi-cmd">5.3.7.
comedi_cmd
</a></span></dt><dt><span class="section"><a href="datatypesstructures.html#ref-type-comedi-insn">5.3.8.
comedi_insn
</a></span></dt><dt><span class="section"><a href="datatypesstructures.html#ref-type-comedi-range">5.3.9.
comedi_range
</a></span></dt><dt><span class="section"><a href="datatypesstructures.html#ref-type-comedi-krange">5.3.10.
comedi_krange
</a></span></dt><dt><span class="section"><a href="datatypesstructures.html#ref-type-comedi-insnlist">5.3.11.
comedi_insnlist
</a></span></dt><dt><span class="section"><a href="datatypesstructures.html#ref-type-comedi-polynomial-t">5.3.12.
comedi_polynomial_t
</a></span></dt></dl></div><p>
This Section explains the data structures that users of the <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a>
API are confronted with:
</p><pre class="programlisting">
typedef struct comedi_devinfo_struct <a class="link" href="datatypesstructures.html#ref-type-comedi-devinfo" title="5.3.1. comedi_devinfo">comedi_devinfo</a>;
typedef struct comedi_t_struct <a class="link" href="datatypesstructures.html#ref-type-comedi-t" title="5.3.2. comedi_t">comedi_t</a>;
typedef struct sampl_t_struct <a class="link" href="datatypesstructures.html#ref-type-sampl-t" title="5.3.3. sampl_t">sampl_t</a>;
typedef struct lsampl_t_struct <a class="link" href="datatypesstructures.html#ref-type-lsampl-t" title="5.3.4. lsampl_t">lsampl_t</a>;
typedef struct comedi_sv_t_struct <a class="link" href="datatypesstructures.html#ref-type-comedi-sv-t" title="5.3.6. comedi_sv_t (deprecated)">comedi_sv_t</a>;
typedef struct comedi_cmd_struct <a class="link" href="datatypesstructures.html#ref-type-comedi-cmd" title="5.3.7. comedi_cmd">comedi_cmd</a>;
typedef struct comedi_insn_struct <a class="link" href="datatypesstructures.html#ref-type-comedi-insn" title="5.3.8. comedi_insn">comedi_insn</a>;
typedef struct comedi_range_struct <a class="link" href="datatypesstructures.html#ref-type-comedi-range" title="5.3.9. comedi_range">comedi_range</a>;
typedef struct comedi_krange_struct <a class="link" href="datatypesstructures.html#ref-type-comedi-krange" title="5.3.10. comedi_krange">comedi_krange</a>;
typedef struct comedi_insnlist_struct <a class="link" href="datatypesstructures.html#ref-type-comedi-insnlist" title="5.3.11. comedi_insnlist">comedi_insnlist</a>;
</pre><p>
The data structures used in the implementation of the <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> drivers
are described in <a class="xref" href="comedikernelgeneric.html#driverdatastructures" title="6.2.1. Data structures">Section 6.2.1</a>.
</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-comedi-devinfo"></a>5.3.1.
comedi_devinfo
</h4></div></div></div><p>
The data type <span class="type">comedi_devinfo</span> is used to store
information about a device. This structure is usually filled in
automatically when the driver is loaded (<span class="quote">“<span class="quote">attached</span>”</span>), so
programmers need not access this data structure directly.
</p><pre class="programlisting">
typedef struct comedi_devinfo_struct comedi_devinfo;
struct comedi_devinfo_struct{
unsigned int version_code; // version number of the Comedi code
unsigned int n_subdevs; // number of subdevices on this device
char driver_name[COMEDI_NAMELEN];
char board_name[COMEDI_NAMELEN];
int read_subdevice; // index of subdevice whose buffer is read by read(), etc. on file descriptor from comedi_fileno() (negative means none)
int write_subdevice; // index of subdevice whose buffer is written by write(), etc. on file descriptor from comedi_fileno() (negatove means none).
int unused[30];
};
</pre><p>
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-comedi-t"></a>5.3.2.
comedi_t
</h4></div></div></div><p>
The data type <span class="type">comedi_t</span> is used to represent an
open <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> device:
</p><pre class="programlisting">
typedef struct comedi_t_struct comedi_t;
</pre><p>
A valid <span class="type">comedi_t</span> pointer is returned by a
successful call to
<code class="function"><a class="link" href="func-ref-comedi-open.html" title="comedi_open">comedi_open</a></code>,
and should be used for subsequent access to the device.
It is an opaque type, and pointers to type
<em class="parameter"><code>comedi_t</code></em>
should not be dereferenced by the application.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-sampl-t"></a>5.3.3.
sampl_t
</h4></div></div></div><pre class="programlisting">
typedef unsigned short sampl_t;
</pre><p>
The data type <span class="type">sampl_t</span> is one
of the generic
types used to represent data values in Comedilib. It is used in a few
places where a data type
shorter than <span class="type"><a class="link" href="datatypesstructures.html#ref-type-lsampl-t" title="5.3.4. lsampl_t">lsampl_t</a></span> is
useful. On most architectures it is a 16-bit, unsigned integer.
</p><p>
Most drivers represent data transferred by <code class="function">read</code> and
<code class="function">write</code> functions using <span class="type">sampl_t</span>.
Applications should check the subdevice flag
<code class="constant">SDF_LSAMPL</code> to determine if the subdevice uses
<span class="type">sampl_t</span> or
<span class="type"><a class="link" href="datatypesstructures.html#ref-type-lsampl-t" title="5.3.4. lsampl_t">lsampl_t</a></span>.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-lsampl-t"></a>5.3.4.
lsampl_t
</h4></div></div></div><pre class="programlisting">
typedef unsigned int lsampl_t;
</pre><p>
The data type
<span class="type"><a class="link" href="datatypesstructures.html#ref-type-lsampl-t" title="5.3.4. lsampl_t">lsampl_t</a></span>
is the data type typically used to represent
data values in Comedilib. On most architectures it is a 32-bit,
unsigned integer.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-comedi-trig"></a>5.3.5.
comedi_trig (deprecated)
</h4></div></div></div><pre class="programlisting">
typedef struct comedi_trig_struct comedi_trig;
struct comedi_trig_struct{
unsigned int subdev; /* subdevice */
unsigned int mode; /* mode */
unsigned int flags;
unsigned int n_chan; /* number of channels */
unsigned int *chanlist; /* channel/range list */
<a class="link" href="datatypesstructures.html#ref-type-sampl-t" title="5.3.3. sampl_t">sampl_t</a> *data; /* data list, size depends on subd flags */
unsigned int n; /* number of scans */
unsigned int trigsrc;
unsigned int trigvar;
unsigned int trigvar1;
unsigned int data_len;
unsigned int unused[3];
};
</pre><p>
The <span class="type">comedi_trig</span> structure is a control structure used by the
<code class="constant">COMEDI_TRIG</code> ioctl, an older method of communicating
instructions to the driver and hardware. Use of <span class="type">comedi_trig</span> is
deprecated, and is no longer implemented by the <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> kernel layer.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-comedi-sv-t"></a>5.3.6.
comedi_sv_t (deprecated)
</h4></div></div></div><pre class="programlisting">
typedef struct comedi_sv_struct comedi_sv_t;
struct comedi_sv_struct{
comedi_t *dev;
unsigned int subdevice;
unsigned int chan;
/* range policy */
int range;
int aref;
/* number of measurements to average (for ai) */
int n;
<a class="link" href="datatypesstructures.html#ref-type-lsampl-t" title="5.3.4. lsampl_t">lsampl_t</a> maxdata;
};
</pre><p>
The <span class="type">comedi_sv_t</span> structure is used by the <code class="function">comedi_sv_…</code>
functions to provide a simple method of accurately measuring
slowly varying inputs. This relies on the <code class="constant">COMEDI_TRIG</code>
ioctl and is no longer by the <a class="ulink" href="http://www.comedi.org" target="_top"><acronym class="acronym">Comedi</acronym></a> kernel layer.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-comedi-cmd"></a>5.3.7.
comedi_cmd
</h4></div></div></div><pre class="programlisting">
typedef struct comedi_cmd_struct comedi_cmd;
struct comedi_cmd_struct{
unsigned int subdev;
unsigned int flags;
unsigned int start_src;
unsigned int start_arg;
unsigned int scan_begin_src;
unsigned int scan_begin_arg;
unsigned int convert_src;
unsigned int convert_arg;
unsigned int scan_end_src;
unsigned int scan_end_arg;
unsigned int stop_src;
unsigned int stop_arg;
unsigned int *chanlist;
unsigned int chanlist_len;
<a class="link" href="datatypesstructures.html#ref-type-sampl-t" title="5.3.3. sampl_t">sampl_t</a> *data;
unsigned int data_len;
};
</pre><p>
More information on using commands can be found in the
<a class="link" href="commandsstreaming.html" title="4.5. Commands for streaming acquisition">command section</a>.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-comedi-insn"></a>5.3.8.
comedi_insn
</h4></div></div></div><pre class="programlisting">
typedef struct comedi_insn_struct comedi_insn;
struct comedi_insn_struct{
unsigned int insn;
unsigned int n;
<a class="link" href="datatypesstructures.html#ref-type-lsampl-t" title="5.3.4. lsampl_t">lsampl_t</a>*data;
unsigned int subdev;
unsigned int chanspec;
unsigned int unused[3];
};
</pre><p>
Comedi instructions are described by the <span class="type">comedi_insn</span> structure.
Applications send instructions to the driver in order to perform
control and measurement operations that are done immediately or
synchronously, i.e., the operations complete before program control
returns to the application. In particular, instructions cannot
describe acquisition that involves timers or external events.
</p><p>
The field insn determines the type of instruction that is sent
to the driver. Valid instruction types are:
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">
<a name="insn-read"></a>
<code class="constant">INSN_READ</code>
</span></dt><dd><p>
read values from an input channel
</p></dd><dt><span class="term">
<a name="insn-write"></a>
<code class="constant">INSN_WRITE</code>
</span></dt><dd><p>
write values to an output channel
</p></dd><dt><span class="term">
<a name="insn-bits"></a>
<code class="constant">INSN_BITS</code>
</span></dt><dd><p>
read/write values on multiple digital I/O channels
</p></dd><dt><span class="term">
<a name="insn-config"></a>
<code class="constant">INSN_CONFIG</code>
</span></dt><dd><p>
configure a subdevice
</p></dd><dt><span class="term">
<a name="insn-gtod"></a>
<code class="constant">INSN_GTOD</code>
</span></dt><dd><p>
read a timestamp, identical to <code class="function">gettimeofday</code> except the seconds
and microseconds values are unsigned values of type <span class="type"><a class="link" href="datatypesstructures.html#ref-type-lsampl-t" title="5.3.4. lsampl_t">lsampl_t</a></span>.
</p></dd><dt><span class="term">
<a name="insn-wait"></a>
<code class="constant">INSN_WAIT</code>
</span></dt><dd><p>
wait a specified number of nanoseconds
</p></dd></dl></div><p>
The number of samples to read or write, or the size of the configuration
structure is specified by the field n, and the buffer for those
samples by data. The field subdev is the subdevice index
that the instruction is sent to. The field chanspec specifies
the channel, range, and analog reference (if applicable).
</p><p>
Instructions can be sent to drivers using
<code class="function"><a class="link" href="func-ref-comedi-do-insn.html" title="comedi_do_insn">comedi_do_insn</a></code>.
Multiple instructions can be sent to drivers in the same system call using
<code class="function"><a class="link" href="func-ref-comedi-do-insnlist.html" title="comedi_do_insnlist">comedi_do_insnlist</a></code>.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-comedi-range"></a>5.3.9.
comedi_range
</h4></div></div></div><pre class="programlisting">
typedef struct comedi_range_struct comedi_range;
struct comedi_range_struct{
double min;
double max;
unsigned int unit;
}comedi_range;
</pre><p>
The <span class="type">comedi_range</span> structure conveys part of the information
necessary to translate sample values to physical units, in particular,
the endpoints of the range and the physical unit type. The
physical unit type is specified by the field unit, which may
take the values <code class="constant">UNIT_volt</code> for volts,
<code class="constant">UNIT_mA</code> for milliamps,
or <code class="constant">UNIT_none</code> for unitless. The endpoints are specified by
the fields min and max.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-comedi-krange"></a>5.3.10.
comedi_krange
</h4></div></div></div><pre class="programlisting">
typedef struct comedi_krange_struct comedi_krange;
struct comedi_krange_struct{
int min;
int max;
unsigned int flags;
};
</pre><p>
The <span class="type">comedi_krange</span> structure is used to transfer range information
between the driver and Comedilib, and should not normally be used
by applications. The structure conveys the same information as the
comedi_range structure, except the fields min and max
are integers, multiplied by a factor of 1000000 compared to the
counterparts in <span class="type">comedi_range</span>.
</p><p>
In addition, <code class="systemitem">kcomedilib</code> uses the
<span class="type">comedi_krange</span> structure in place
of the <span class="type">comedi_range</span> structure.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-comedi-insnlist"></a>5.3.11.
comedi_insnlist
</h4></div></div></div><pre class="programlisting">
typedef struct comedi_insnlist_struct comedi_insnlist;
struct comedi_insnlist_struct{
unsigned int n_insns;
comedi_insn *insns;
};
</pre><p>
A <span class="type">comedi_insnlist</span> structure is used to communicate
a list of instructions to the driver using the
<code class="function"><a class="link" href="func-ref-comedi-do-insnlist.html" title="comedi_do_insnlist">comedi_do_insnlist</a></code>
function.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="ref-type-comedi-polynomial-t"></a>5.3.12.
comedi_polynomial_t
</h4></div></div></div><pre class="programlisting">
#define COMEDI_MAX_NUM_POLYNOMIAL_COEFFICIENTS 4
typedef struct {
double coefficients[COMEDI_MAX_NUM_POLYNOMIAL_COEFFICIENTS];
double expansion_origin;
unsigned order;
} comedi_polynomial_t;
</pre><p>
A <span class="type">comedi_polynomial_t</span> holds calibration data for a channel of a
subdevice. It is initialized by the
<code class="function"><a class="link" href="func-ref-comedi-get-hardcal-converter.html" title="comedi_get_hardcal_converter">comedi_get_hardcal_converter</a></code>
or <code class="function"><a class="link" href="func-ref-comedi-get-softcal-converter.html" title="comedi_get_softcal_converter">comedi_get_softcal_converter</a></code>
calibration functions and is passed to the
<code class="function"><a class="link" href="func-ref-comedi-to-physical.html" title="comedi_to_physical">comedi_to_physical</a></code>
and <code class="function"><a class="link" href="func-ref-comedi-from-physical.html" title="comedi_from_physical">comedi_from_physical</a></code>
raw/physical conversion functions.
</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="constantsmacros.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="comedireference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="functionreference.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.2.
Constants and macros
</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.4. Functions</td></tr></table></div></body></html>
|