For more information on the CIF Driver, please refer to the Cogent CIF Driver for Hilscher Fieldbus CIF Cards manual.
The DR_ApReadBlock and DR_ApWriteBlock functions access the process I/O data area of the card. The offset and size parameters specify what portion of the buffer area to transfer, and is dependent on the field configuration. Typically, field data is always mapped to the beginning of the block (offset of 0) and is continguous up to the number of bytes defined by the field device (slave) configuration. The output process data buffer is mapped as buffer 0, while 1 will access the input process data buffer.
The DR_ApReadControl and DR_ApWriteControl functions access the control parameter blocks of the card. Only buffer 2 is valid for CIF cards, which provides access to the protocol parameters.
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).
The DR_ApReadStatus function accesses the status blocks of the card. Only buffer 2 is valid for CIF cards, which provides master status as well as field device (slave) status and diagnostic information.
The status of the Hilscher Fieldbus Card is read from buffer 2 with a length of 64, using the function DR_ApReadStatus, as follows:
DR_ApReadStatus (dev, 2, 0, 64, &status, &error)
The offset and length are ignored. Status is a structure of type cif_ApState_t (see the file cif_api.h) and is defined as follows:
typedef struct { unsigned char global_bits; unsigned char bus_status; unsigned char err_rem_addr; unsigned char err_rem_event; unsigned char reserved[28]; unsigned char state [16]; unsigned char diag [16]; } cif_ApState_t;
where:
State Element | Description | Length | |||||
---|---|---|---|---|---|---|---|
global_bits |
| byte | |||||
bus_status |
| byte | |||||
err_rem_addr | Remote address of error source | byte | |||||
err_rem_event | Error number | byte | |||||
state | A bitfield classifying every slave as active (1) or inactive (0) | 16 x byte | |||||
diag | A bitfield showing diagnostic bit of every slave | 16 x byte |
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.