DR_ApReadStatus

DR_ApReadStatus — gets card status information.

Syntax

#include <cogent.h>
int DR_ApReadStatus(int  card_id,
 int  buffer,
 unsigned short  offset,
 unsigned short  size,
 void*  status,
 char**  error);

Arguments

card_id

The ID of the card to be read for status.

buffer

The ID of the requested status buffer (if applicable).

offset

The starting (byte) address of the required data within the specified card buffer (if applicable).

size

The maximum number of bytes to be read.

status

A pointer to a card-dependent structure (at least size bytes long) that will contain the status information for the card.

error

The address of a string pointer. In case of error (non-zero return), the string pointer is set to the corresponding error description string. The error string is contained in a static buffer and remains valid only until the next API call. The parameter may be NULL if no error string is required.

Returns

The integer value 0 if the function was successful, otherwise one of the following error codes:

DR_API_IPC_ERRORS
DR_ERR_CARD_INVALID
DR_ERR_BLK_INVALID
DR_ERR_BLK_OFS_INVALID
DR_ERR_BLK_SIZE_INVALID
DR_ERR_CMD_INVALID

Description

This function obtains the card status information. The status data is dependent on the card.

Example

cif_ApState_t	status;

if (result = DR_ApReadStatus (0, 2, 0, sizeof (cif_ApState_t),
                              &status, &error_str))
        printf ("Error@ReadStatus (%d,%s)\n", result, error_str);
else
{
        printf ("     GlobalState = %s, %s, %s\n",
                (status.GlobalBits & STATE_GLOBAL_CTRL ?
                     "Parm error" : "Parms OK"),
                (status.GlobalBits & STATE_GLOBAL_ACLR ?
                     "AutoClear/Slave error" : "Mode/Slaves OK"),
                (status.GlobalBits & STATE_GLOBAL_NDATA ?
                     "Slave Fatal error" : "Slaves OK"));
        printf ("     DPMState = %2.2X %s\n", status.DPMState,
                (status.DPMState ?
                (status.DPMState & STATE_OPERATE ? "OPERATING":
                (status.DPMState & STATE_STOP ?"STOPPED":
                (status.DPMState & STATE_CLEAR ? "CLEAR" :
                      "Unknown state"))):"OFFLINE"));
        printf ("     Error status: (%d, %d)\n",
                 status.ErrorRemoteAddr, status.ErrorEvent);
        printf ("     Slaves state: ");
        for (i=0; i<16; i++)
                 printf ("%2.2X", status.SlaveState[i]);
        printf ("\n");
        printf ("     Slaves diagnostic bits: ");
        for (i=0; i<16; i++)
                 printf ("%2.2X", status.SlaveDiags[i]);
        printf ("\n");
}

See Also

Hilscher Fieldbus CIF Card in the Cogent C API manual.