Allen-Bradley 1784-KTX Reference Manual page 74

Table of Contents

Advertisement

The routine in Example 7.B reads data from the KTx I/O image tables in
the dual port and copies the results into a buffer supplied by the caller. It
calculates the number of bytes to copy by reading the size of the device
from the KTx status table. If the device is faulted or is not known by the
KTx scanner, it returns an error in the status byte.
Example 7.B
#include "ktx_dp.h"
/* 1784–KTX Scanner Dualport definition */
#include "ktx_err.h"
/* 1784–KTX Scanner error codes */
#include "ktxconst.h" /* 1784–KTX Scanner constants */
UBYTE get_IO_data (KTX_DUALPORT far *dp,
UBYTE link_address, IO_BUFFER *io,
TABLE_NAME io_table)
{
int
i, xfer_size;
UWORD
far *q;
UBYTE
status = SUCCESS;
ADAPTER_CONFIG_INFO far *p;
/**** Validate the input parameters ****/
if (link_address > 127)
return INVALID_ADAPTER_ADDRESS;
if ((io_table != INPUT_TABLE) && (io_table != OUTPUT_TABLE))
return UNKNOWN_IO_TABLE;
/**** Point to the adapter status table ****/
p = &dp–>adapter_status_table[link_address].adapter_config_info;
/**** Return status of adapter to caller ****/
if (!p–>in_scan)
status = ADDRESS_NOT_IN_SCAN_LIST;
else if (!p–>exists)
status = ADAPTER_NONEXISTENT;
/**** Create pointer to I/O image table and get xfer size ****/
xfer_size = 2 * (p–>size + 1);
if (io_table == INPUT_TABLE)
q = &dp–>input_image_table[link_address * 2];
else
q = &dp–>output_image_table[link_address * 2];
/**** Transfer the data
io–>count = xfer_size;
for (i=0; i<xfer_size; i++, q++)
io–>data[i] = *q;
return status;
}
Chapter 7
Understanding Discrete I/O
****/
7-5

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents