The control parameters for the Hilscher Fieldbus card use the following structure (see file cif_api.h):
typedef struct {
unsigned char Mode;
unsigned char reserved1;
unsigned char Format;
unsigned short WatchdogTime;
unsigned char reserved5[3];
unsigned char reserved8[8];
} cif_ApParms_t;The control parameters do vary with the specific fieldbus protocol and additional structure definitions can be found in the cif_api.h file.
Access to the control data is accomplished via buffer 2 with a length of 16, using the functions DR_ApReadControl and DR_ApWriteControl, as follows:
DR_ApReadControl (dev, 2, 0, 16, &control, &error)
DR_ApWriteControl (dev, 2, 0, 16, &control, &error)It is recommended that reserved bytes be set to 0. Most protocols reserve the last 11 bytes, so the length may be shortened to 5, depending on the protocol. Note that a read of the control parameters may return only zero data from some cards.
The components of the control structure are defined as follows:
| Parameter | Description | Length |
|---|---|---|
| Mode | Type of handshake mechanism for process data delivery. | byte |
| Cycle_time | Cycle time of the fieldbus cycle (hwere applicable). | byte |
| Format | Storage format of word data. | byte |
| WatchdogTime | HOST-supervision time in multiples of a msec. | short |
The handshake modes available are:
| Mode | Name (see cif_api.h) | Description |
|---|---|---|
| 0 | IOMODE_DEV_UNBUF | card controlled, bus synchronous data transfer |
| 1 | IOMODE_DEV_BUF | card controlled, buffered data transfer |
| 2 | IOMODE_NO_CTL | no handshake |
| 3 | IOMODE_HOST_BUF | HOST controlled, buffered data transfer |
| 4 | IOMODE_HOST_UNBUF | HOST controlled, bus synchronous data transfer |
Not all modes are available for all protocols.
The available storage formats are:
| Format | Name (see cif_api.h) | Description |
|---|---|---|
| 0 | FORMAT_INTEL | Intel; little-endian; low-byte, high-byte |
| 1 | FORMAT_MOTORLA | Motorola; big-endian; high-byte, low-byte |
After writing the control block, the system must do a WARM reset before the changes will take effect (see the cardReset command in the Device Driver for Hilscher CIF Cards manual).