4.3. Instructions for configuration
Prev | 4. Acquisition and configuration functions | Next

### 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 acquisition 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 (number of elements 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

`INSN_CONFIG_ALT_SOURCE`

Select an alternate input source. This instruction is used by calibration programs to configure analog input channels which can be redirected to read internal calibration references. You need to set the `CR_ALT_SOURCE` flag in the chanspec when reading to actually read from the configured alternate input source. If you are using `comedi_data_read`, then the channel parameter can be bitwise or'd with the `CR_ALT_SOURCE` flag.

2

data[1]: alternate input source.

`INSN_CONFIG_BLOCK_SIZE`

Specify block size for asynchonous command data. When performing streaming input, many boards accumulate samples in internal fifos and transfer them to the host computer in chunks. Some drivers let you suggest a size in bytes for how big a the chunks should be. This lets you tune how often the host computer is interrupted with a new chunk of data.

2

data[1]: The desired block size in bytes. The actual configured block size is writen back to data[1] after the instruction completes. This instruction acts purely as a query if the block size is set to zero.

`INSN_CONFIG_DIO_QUERY` | Queries the configuration of a DIO line to see if it is an input or output. It is probably easier to use the comedilib function `comedi_dio_get_config` than to use this instruction directly. | 2 | data[1]: The instruction sets this element to either `COMEDI_INPUT` or `COMEDI_OUTPUT`.

See the comedilib demo program `demo/choose_clock.c` for an example of using a configuration instruction.

Prev | Up | Next
4.2. Instructions for multiple acquisitions | Home | 4.4. Instruction for internal triggering