1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
9
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
13
HREF="index.html"><LINK
15
TITLE=" Low-level drivers
17
HREF="x1672.html"><LINK
20
HREF="r3764.html"></HEAD
31
SUMMARY="Header navigation table"
44
>Control and Measurement Device Interface</I
84
NAME="COMEDIREFERENCE"
93
HREF="x3563.html#CONSTANTSMACROS"
94
>constants and macros</A
97
HREF="x3563.html#DATATYPESSTRUCTURES"
98
>data types and structures</A
101
HREF="x3563.html#FUNCTIONREFERENCE"
110
NAME="COMEDI-COMEDILIB-H"
111
>7.1. Headerfiles: <TT
122
>application programs</A
124
include the header file <TT
131
>.) They contain the full
132
interface of <ACRONYM
135
>: defines, function prototypes, data structures.</P
137
>The following Sections give more details.</P
144
NAME="CONSTANTSMACROS"
145
>7.2. Constants and Macros</A
152
NAME="REF-MACRO-CR-PACK"
156
>CR_PACK is used to initialize the elements of the
162
HREF="x3563.html#REF-TYPE-COMEDI-CMD"
170
HREF="x3563.html#REF-TYPE-COMEDI-INSN"
174
CLASS="PROGRAMLISTING"
175
>#define CR_PACK(chan,rng,aref) ( (((aref)&0x3)<<24) | (((rng)&0xff)<<16) | (chan) ) </PRE
180
> argument is the channel you wish to
181
use, with the channel numbering starting at zero.</P
186
> is an index, starting at zero,
187
whose meaning is device dependent. The
190
>comedi_get_n_ranges()</A
195
>comedi_get_range()</A
197
functions are useful in discovering information about the available
203
> argument indicates what reference you
204
want the device to use. It can be any of the following:
217
> is for inputs/outputs referenced to ground.
230
> reference (the low inputs of all the
231
channels are tied together, but are isolated from ground).
241
> is for differential inputs/outputs.
251
> is for any reference that does not fit into the above categories.
257
Particular drivers may or may not use the AREF flags. If they are
258
not supported, they are silently ignored.</P
265
NAME="REF-MACRO-RANGE-LENGTH"
266
>7.2.2. RANGE_LENGTH (deprecated)</A
269
>Rangetype values are library-internal tokens that represent an
270
array of range information structures. These numbers are primarily
271
used for communication between the kernel and library.</P
273
>The RANGE_LENGTH() macro returns the length of the array that is
274
specified by the rangetype token.</P
276
>The RANGE_LENGTH() macro is deprecated, and should not be used in
277
new applications. It is scheduled to be removed from the header
278
file at version 1.0. Binary compatibility may be broken for version
287
NAME="DATATYPESSTRUCTURES"
288
>7.3. Data Types and Structures</A
291
>This Section explains the data structures that users of the <ACRONYM
295
API are confronted with:
297
CLASS="PROGRAMLISTING"
298
>typedef struct subdevice_struct <A
299
HREF="x3563.html#REF-TYPE-SUBDEVICE-STRUCT"
302
typedef struct comedi_devinfo_struct <A
303
HREF="x3563.html#REF-TYPE-COMEDI-DEVINFO"
306
typedef struct comedi_t_struct <A
307
HREF="x3563.html#REF-TYPE-COMEDI-T"
310
typedef struct sampl_t_struct <A
311
HREF="x3563.html#REF-TYPE-SAMPL-T"
314
typedef struct lsampl_t_struct <A
315
HREF="x3563.html#REF-TYPE-LSAMPL-T"
318
typedef struct comedi_sv_t_struct <A
319
HREF="x3563.html#REF-TYPE-COMEDI-SV-T"
322
typedef struct comedi_cmd_struct <A
323
HREF="x3563.html#REF-TYPE-COMEDI-CMD"
326
typedef struct comedi_insn_struct <A
327
HREF="x3563.html#REF-TYPE-COMEDI-INSN"
330
typedef struct comedi_range_struct <A
331
HREF="x3563.html#REF-TYPE-COMEDI-RANGE"
334
typedef struct comedi_krange_struct <A
335
HREF="x3563.html#REF-TYPE-COMEDI-KRANGE"
338
typedef struct comedi_insnlist_struct <A
339
HREF="x3563.html#REF-TYPE-COMEDI-INSNLIST"
343
The data structures used in the implementation of the <ACRONYM
348
HREF="x1283.html#DRIVERDATASTRUCTURES"
356
NAME="REF-TYPE-SUBDEVICE-STRUCT"
357
>7.3.1. subdevice_struct</A
362
>subdevice_struct</VAR
364
information about a subdevice. This structure is usually filled in
365
automatically when the driver is loaded (<SPAN
369
programmers need not access this data structure directly.
371
CLASS="PROGRAMLISTING"
372
>typedef struct subdevice_struct <A
373
NAME="REF-TYPE-SUBDEVICE"
377
struct subdevice_struct{
380
unsigned int subd_flags;
381
unsigned int timer_type;
382
unsigned int len_chanlist;
384
HREF="x3563.html#REF-TYPE-LSAMPL-T"
388
unsigned int range_type;
391
HREF="x3563.html#REF-TYPE-LSAMPL-T"
394
unsigned int *range_type_list;
395
unsigned int *flags_list;
398
HREF="x3563.html#REF-TYPE-COMEDI-RANGE"
402
HREF="x3563.html#REF-TYPE-COMEDI-RANGE"
406
unsigned int has_cmd;
407
unsigned int has_insn_bits;
411
HREF="x3563.html#REF-TYPE-COMEDI-CMD"
416
HREF="x3563.html#REF-TYPE-COMEDI-CMD"
427
NAME="REF-TYPE-COMEDI-DEVINFO"
428
>7.3.2. comedi_devinfo</A
435
information about a device. This structure is usually filled in
436
automatically when the driver is loaded (<SPAN
440
programmers need not access this data structure directly.
442
CLASS="PROGRAMLISTING"
443
>typedef struct comedi_devinfo_struct comedi_devinfo;
445
struct comedi_devinfo_struct{
446
unsigned int version_code; // version number of the Comedi code
447
unsigned int n_subdevs; // number of subdevices on this device
448
char driver_name[COMEDI_NAMELEN];
449
char board_name[COMEDI_NAMELEN];
450
int read_subdevice; // number of read devices
451
int write_subdevice; // number of write devices
461
NAME="REF-TYPE-COMEDI-T"
468
> is used to represent an
474
CLASS="PROGRAMLISTING"
475
>typedef struct comedi_t_struct comedi_t;
477
struct comedi_t_struct{
478
int magic; // driver-specific magic number, for identification
479
int fd; // file descriptor, for open() and close()
480
int n_subdevices; // number of subdevices on this device
482
HREF="x3563.html#REF-TYPE-COMEDI-DEVINFO"
486
HREF="x3563.html#REF-TYPE-SUBDEVICE"
488
> *subdevices; // pointer to subdevice list
489
// filled in automatically at load time
490
unsigned int has_insnlist_ioctl; // can process <A
491
HREF="x621.html#ANCHOR.INSTRUCTION.LIST"
492
>instruction lists</A
494
unsigned int has_insn_ioctl; // can process <A
495
HREF="x621.html#INSTRUCTIONS"
503
> pointer is returned by a
509
and should be used for subsequent access to the device.
510
It is a transparent type, and pointers to type
515
should not be dereferenced by the application.</P
522
NAME="REF-TYPE-SAMPL-T"
526
CLASS="PROGRAMLISTING"
527
>typedef unsigned short sampl_t;</PRE
530
HREF="x3563.html#REF-TYPE-SAMPL-T"
534
types used to represent data values in Comedilib. It is used in a few
535
places where a data type
537
HREF="x3563.html#REF-TYPE-LSAMPL-T"
540
useful. On most architectures,
542
HREF="x3563.html#REF-TYPE-SAMPL-T"
545
is defined to be <VAR
550
>Most drivers represent data transferred by <CODE
559
HREF="x3563.html#REF-TYPE-SAMPL-T"
562
Applications should check the subdevice flag
563
SDF_LSAMPL to determine if the subdevice uses
565
HREF="x3563.html#REF-TYPE-SAMPL-T"
569
HREF="x3563.html#REF-TYPE-LSAMPL-T"
578
NAME="REF-TYPE-LSAMPL-T"
582
CLASS="PROGRAMLISTING"
583
>typedef unsigned int lsampl_t;</PRE
587
HREF="x3563.html#REF-TYPE-LSAMPL-T"
590
is the data type typically used to represent
591
data values in libcomedi. On most architectures,
593
HREF="x3563.html#REF-TYPE-LSAMPL-T"
596
is defined to be uint32.</P
603
NAME="REF-TYPE-COMEDI-TRIG"
604
>7.3.6. comedi_trig (deprecated)</A
607
CLASS="PROGRAMLISTING"
608
>typedef struct comedi_trig_struct comedi_trig;
610
struct comedi_trig_struct{
611
unsigned int subdev; /* subdevice */
612
unsigned int mode; /* mode */
614
unsigned int n_chan; /* number of channels */
615
unsigned int *chanlist; /* channel/range list */
617
HREF="x3563.html#REF-TYPE-SAMPL-T"
619
> *data; /* data list, size depends on subd flags */
620
unsigned int n; /* number of scans */
621
unsigned int trigsrc;
622
unsigned int trigvar;
623
unsigned int trigvar1;
624
unsigned int data_len;
625
unsigned int unused[3];
628
>The comedi_trig structure is a control structure used by the
629
COMEDI_TRIG ioctl, an older method of communicating
630
instructions to the driver and hardware. Use of comedi_trig is
631
deprecated, and should not be used in new applications.</P
638
NAME="REF-TYPE-COMEDI-SV-T"
639
>7.3.7. comedi_sv_t</A
642
CLASS="PROGRAMLISTING"
643
>typedef struct comedi_sv_struct comedi_sv_t;
645
struct comedi_sv_struct{
647
unsigned int subdevice;
654
/* number of measurements to average (for ai) */
658
HREF="x3563.html#REF-TYPE-LSAMPL-T"
663
>The comedi_sv_t structure is used by the comedi_sv_*()
664
functions to provide a simple method of accurately measuring
665
slowly varying inputs. See the relevant section for more
673
NAME="REF-TYPE-COMEDI-CMD"
674
>7.3.8. comedi_cmd</A
677
CLASS="PROGRAMLISTING"
678
>typedef struct comedi_cmd_struct comedi_cmd;
680
struct comedi_cmd_struct{
684
unsigned int start_src;
685
unsigned int start_arg;
687
unsigned int scan_begin_src;
688
unsigned int scan_begin_arg;
690
unsigned int convert_src;
691
unsigned int convert_arg;
693
unsigned int scan_end_src;
694
unsigned int scan_end_arg;
696
unsigned int stop_src;
697
unsigned int stop_arg;
699
unsigned int *chanlist;
700
unsigned int chanlist_len;
703
HREF="x3563.html#REF-TYPE-SAMPL-T"
706
unsigned int data_len;
709
>More information on using commands can be found in the
717
NAME="REF-TYPE-COMEDI-INSN"
718
>7.3.9. comedi_insn</A
721
CLASS="PROGRAMLISTING"
722
>typedef struct comedi_insn_struct comedi_insn;
724
struct comedi_insn_struct{
728
HREF="x3563.html#REF-TYPE-LSAMPL-T"
732
unsigned int chanspec;
733
unsigned int unused[3];
736
>Comedi instructions are described by the comedi_insn structure.
737
Applications send instructions to the driver in order to perform
738
control and measurement operations that are done immediately or
739
synchronously, i.e., the operations complete before program control
740
returns to the application. In particular, instructions cannot
741
describe acquisition that involves timers or external events.</P
743
>The field insn determines the type of instruction that is sent
744
to the driver. Valid instruction types are:</P
758
>read values from an input channel
769
>write values to an output channel
780
>read/write values on multiple digital I/O channels
791
>configure a subdevice
802
>read a timestamp, identical to gettimeofday()
813
>wait a specified number of nanoseconds
819
>The number of samples to read or write, or the size of the configuration
820
structure is specified by the field n, and the buffer for those
821
samples by data. The field subdev is the subdevice index
822
that the instruction is sent to. The field chanspec specifies
823
the channel, range, and analog reference (if applicable).</P
825
>Instructions can be sent to drivers using comedi_do_insn().
826
Multiple instructions can be sent to drivers in the same system
827
call using comedi_do_insnlist().</P
834
NAME="REF-TYPE-COMEDI-RANGE"
835
>7.3.10. comedi_range</A
838
CLASS="PROGRAMLISTING"
839
>typedef struct comedi_range_struct comedi_range;
841
struct comedi_range_struct{
847
>The comedi_range structure conveys part of the information
848
necessary to translate sample values to physical units, in particular,
849
the endpoints of the range and the physical unit type. The
850
physical unit type is specified by the field unit, which may
851
take the values UNIT_volt for volts, UNIT_mA for milliamps,
852
or UNIT_none for unitless. The endpoints are specified by
853
the fields min and max.</P
860
NAME="REF-TYPE-COMEDI-KRANGE"
861
>7.3.11. comedi_krange</A
864
CLASS="PROGRAMLISTING"
865
>typedef struct comedi_krange_struct comedi_krange;
867
struct comedi_krange_struct{
873
>The comedi_krange structure is used to transfer range information
874
between the driver and Comedilib, and should not normally be used
875
by applications. The structure conveys the same information as the
876
comedi_range structure, except the fields min and max
877
are integers, multiplied by a factor of 1000000 compared to the
878
counterparts in comedi_range.</P
880
>In addition, kcomedilib uses the comedi_krange structure in place
881
of the comedi_range structure.</P
888
NAME="REF-TYPE-COMEDI-INSNLIST"
889
>7.3.12. comedi_insnlist</A
892
CLASS="PROGRAMLISTING"
893
>typedef struct comedi_insnlist_struct comedi_insnlist;
895
struct comedi_insnlist_struct{
896
unsigned int n_insns;
900
>An instruction list (insnlist) structure is used to communicate
901
a list of instructions.</P
909
NAME="FUNCTIONREFERENCE"
910
>7.4. Comedi Function Reference</A
917
>Table of Contents</B
923
> -- close a Comedi device</DT
928
> -- open a Comedi device</DT
933
> -- change Comedilib logging properties</DT
938
> -- print a Comedilib error message</DT
943
> -- return string describing Comedilib error code</DT
948
> -- number of last Comedilib error</DT
953
> -- integer descriptor of Comedilib device</DT
957
>comedi_get_n_subdevices</A
958
> -- number of subdevices </DT
962
>comedi_get_version_code</A
963
> -- Comedi version code</DT
967
>comedi_get_driver_name</A
968
> -- Comedi driver name</DT
972
>comedi_get_board_name</A
973
> -- Comedi device name</DT
977
>comedi_get_subdevice_type</A
978
> -- type of subdevice</DT
982
>comedi_find_subdevice_by_type</A
983
> -- search for subdevice type</DT
987
>comedi_get_read_subdevice</A
988
> -- find streaming input subdevice</DT
992
>comedi_get_write_subdevice</A
993
> -- find streaming output subdevice</DT
997
>comedi_get_subdevice_flags</A
998
> -- properties of subdevice</DT
1002
>comedi_get_n_channels</A
1003
> -- number of subdevice channels</DT
1007
>comedi_range_is_chan_specific</A
1008
> -- range information depends on channel</DT
1012
>comedi_maxdata_is_chan_specific</A
1013
> -- maximum sample depends on channel</DT
1017
>comedi_get_maxdata</A
1018
> -- maximum sample of channel</DT
1022
>comedi_get_n_ranges</A
1023
> -- number of ranges of channel</DT
1027
>comedi_get_range</A
1028
> -- range information of channel</DT
1032
>comedi_find_range</A
1033
> -- search for range</DT
1037
>comedi_get_buffer_size</A
1038
> -- streaming buffer size of subdevice</DT
1042
>comedi_get_max_buffer_size</A
1043
> -- maximum streaming buffer size</DT
1047
>comedi_set_buffer_size</A
1048
> -- streaming buffer size of subdevice</DT
1053
> -- perform streaming input/output (deprecated)</DT
1057
>comedi_do_insnlist</A
1058
> -- perform multiple instructions</DT
1063
> -- perform instruction</DT
1068
> -- subdevice reservation</DT
1073
> -- subdevice reservation</DT
1078
> -- convert sample to physical units</DT
1082
>comedi_from_phys</A
1083
> -- convert physical units to sample</DT
1087
>comedi_data_read</A
1088
> -- read single sample from channel</DT
1092
>comedi_data_read_delayed</A
1093
> -- read single sample from channel after delaying for specified settling time</DT
1097
>comedi_data_read_hint</A
1098
> -- tell driver which channel/range/aref you are going to read from next</DT
1102
>comedi_data_write</A
1103
> -- write single sample to channel</DT
1107
>comedi_dio_config</A
1108
> -- change input/output properties of channel</DT
1113
> -- read single bit from digital channel</DT
1117
>comedi_dio_write</A
1118
> -- write single bit to digital channel</DT
1122
>comedi_dio_bitfield</A
1123
> -- read/write multiple digital channels</DT
1128
> -- slowly-varying inputs</DT
1132
>comedi_sv_update</A
1133
> -- slowly-varying inputs</DT
1137
>comedi_sv_measure</A
1138
> -- slowly-varying inputs</DT
1142
>comedi_get_cmd_src_mask</A
1143
> -- streaming input/output capabilities</DT
1147
>comedi_get_cmd_generic_timed</A
1148
> -- streaming input/output capabilities</DT
1153
> -- stop streaming input/output in progress</DT
1158
> -- start streaming input/output</DT
1162
>comedi_command_test</A
1163
> -- test streaming input/output configuration</DT
1168
> -- force updating of streaming buffer</DT
1172
>comedi_set_max_buffer_size</A
1173
> -- streaming buffer size of subdevice</DT
1177
>comedi_get_buffer_contents</A
1178
> -- streaming buffer status</DT
1182
>comedi_mark_buffer_read</A
1183
> -- streaming buffer status</DT
1187
>comedi_get_buffer_offset</A
1188
> -- streaming buffer status</DT
1192
>comedi_get_timer</A
1193
> -- timer information (deprecated)</DT
1197
>comedi_timed_1chan</A
1198
> -- streaming input (deprecated)</DT
1202
>comedi_set_global_oor_behavior</A
1203
> -- out-of-range behavior</DT
1207
>comedi_apply_calibration</A
1208
> -- set calibration from file</DT
1212
>comedi_apply_parsed_calibration</A
1213
> -- set calibration from memory</DT
1217
>comedi_cleanup_calibration_file</A
1218
> -- free calibration resources</DT
1222
>comedi_get_default_calibration_path</A
1223
> -- get default calibration file path</DT
1227
>comedi_parse_calibration_file</A
1228
> -- set calibration</DT
1238
SUMMARY="Footer navigation table"
1277
>Low-level drivers</TD
b'\\ No newline at end of file'