Specifications

Comedi
17 / 148
4.2.2 Instruction execution
Once an instruction data structure has been filled in, the corresponding instruction is executed with the function comedi_do-
_insn():
int comedi_do_insn(comedi_t *device, comedi_insn *instruction);
Many Comedi instructions are shortcuts that relieve the programmer from explicitly filling in the data structure and calling the
comedi_do_insn() function.
A list of instructions can be executed in one function call using the function comedi_do_insnlist():
int comedi_do_insnlist(comedi_t *device, comedi_insnlist *list);
The parameter list is a pointer to a comedi_insnlist data structure holding a pointer to an array of comedi_insn and the number
of instructions in the list:
typedef struct comedi_insnlist_struct {
unsigned int n_insns;
comedi_insn
*
insns;
} comedi_insnlist;
The number of instructions in the list is limited in the implementation, because instructions are executed synchronously, i.e., the
call blocks until the whole instruction (list) has finished.
4.3 Instructions for configuration
Section 4.2 explains how instructions are used to do acquisition on channels. This section explains how they are used to configure
a subdevice. There are various sorts of configurations, and the specific information for each different configuration possibility is
to be specified via the data buffer of the instruction data structure. (So, the pointer to a lsampl_t is misused as a pointer to an
array with board-specific information.)
Using INSN_CONFIG as the insn member in an instruction data structure indicates that the instruction will not perform ac-
quisition on a channel, but will configure that channel. The chanspec member in the comedi_insn data structure, contains the
channel to be configured. The zeroth element of the data array is always an id that specifies what type of configuration instruction
is being performed. The meaning of rest of the elements in the data array depend on the configuration instruction id. Some of the
possible ids are summarised in the table below, along with the meanings of the data array elements for each type of configuration
instruction.
data[0] Description
n (num-
ber of
ele-
ments
in data
array)
Meanings of data[1], ...,
data[n-1]
INSN_CONFIG_DIO_INPUT
Configure a DIO line as input. It is
easier to use
comedi_dio_config() than to
use this configuration instruction
directly.
1 n/a
INSN_CONFIG_DIO_OUTPUT
Configure a DIO line as output. It
is easier to use
comedi_dio_config() than to
use this configuration instruction
directly.
1 n/a