Specifications
Comedi
20 / 148
unsigned int stop_src; // what make the acquisition terminate
unsigned int stop_arg; // parameters that influence this termination
unsigned int
*
chanlist; // pointer to list of channels to be sampled
unsigned int chanlist_len; // number of channels to be sampled
sampl_t
*
data; // address of buffer
unsigned int data_len; // number of samples to acquire
};
The start and end of the whole command acquisition sequence, and the start and end of each scan and of each conversion, is
triggered by a so-called event. More on these in Section 4.5.3.
The subdev member of the comedi_cmd structure is the index of the subdevice the command is intended for. The comedi_f-
ind_subdevice_by_type() function can be useful in discovering the index of your desired subdevice.
The chanlist member of the comedi_cmd data structure should point to an array whose number of elements is specified by
chanlist_len (this will generally be the same as the scan_end_arg). The chanlist specifies the sequence of channels and
gains (and analog references) that should be stepped through for each scan. The elements of the chanlist array should be
initialized by ‘packing’ the channel, range and reference information together with the CR_PACK() macro.
The data and data_len members can be safely ignored when issueing commands from a user-space program. They only have
meaning when a command is sent from a kernel module using the kcomedilib interface, in which case they specify the buffer
where the driver should write/read its data to/from.
The final member of the comedi_cmd structure is the flags field, i.e., bits in a word that can be bitwise-or’d together. The
meaning of these bits are explained in Section 4.5.4.
4.5.3 The command trigger events
A command is a very versatile acquisition instruction, in the sense that it offers lots of possibilities to let different hardware
and software sources determine when acquisitions are started, performed, and stopped. More specifically, the command data
structure has five types of events: start the acquisition, start a scan, start a conversion, stop a scan, and stop the acquisition. Each
event can be given its own source (the ..._src members in the comedi_cmd data structure). And each event source can have
a corresponding argument (the ..._arg members of the comedi_cmd data structure) whose meaning depends on the type of
source trigger. For example, to specify an external digital line ‘3’ as a source (in general, any of the five event sources), you
would use src=TRIG_EXT and arg=3.
The following paragraphs discuss in somewhat more detail the trigger event sources(..._src), and the corresponding arguments
(..._arg).
The start of an acquisition is controlled by the start_src events. The available options are:
• TRIG_NOW: the ‘start’ event occurs start_arg nanoseconds after the command is set up. Currently, only start_arg=0 is
supported.
• TRIG_FOLLOW: (For an output device.) The ‘start’ event occurs when data is written to the buffer.
• TRIG_EXT: the ‘start’ event occurs when an external trigger signal occurs; e.g., a rising edge of a digital line. start_arg
chooses the particular digital line.
• TRIG_INT: the ‘start’ event occurs on a Comedi internal signal, which is typically caused by an INSN_INTTRIG instruction.
The start of the beginning of each scan is controlled by the scan_begin_src events. The available options are:
• TRIG_TIMER: ‘scan begin’ events occur periodically. The time between ‘scan begin’ events is scan_begin_arg nanosec-
onds.
• TRIG_FOLLOW: The ‘scan begin’ event occurs immediately after a ‘scan end’ event occurs.