Allen-Bradley 1784-KTX Reference Manual page 97

Table of Contents

Advertisement

Appendix B
Programming Examples
/***************************************************************************
**
**
UBYTE get_IO_data (KTX_DUALPORT far *dp, UBYTE link_address,
**
IO_BUFFER *io, TABLE_NAME io_table)
**
**
This routine reads data from the KTX I/O Image Tables in the dualport
**
and copies the results into a buffer supplied by the caller.
**
calculates the number of bytes to copy by reading the size of the
**
device from the KTX status table.
**
known by the KTX scanner, it returns a error in the status byte.
**
**
INPUT
**
KTX_DUALPORT far *dp – points to the base of the KTX dualport
**
UYBTE link_address – address of device whose data is to be read
**
IO_BUFFER *io – if successful, I/O data will be assigned to
**
**
TABLE_NAME io_table – either INPUT_TABLE or OUTPUT_TABLE,
**
**
**
**
OUTPUT
**
UBYTE status – completion status of the command
**
***************************************************************************/
#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,
{
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;
Allen-Bradley Parts
return status;
}
B-18
read_iot.c file
If the device is faulted or is not
this variable
which is used to create a pointer to the
right table
TABLE_NAME io_table)
It
*/
*/
*/

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents