Allen-Bradley 1784-KTX Reference Manual page 96

Table of Contents

Advertisement

/*************************************************************************************
**
**
UBYTE put_output_data (KTX_DUALPORT far *dp, UBYTE link_address, IO_BUFFER *io)
**
**
This routine writes data into the KTX Output Image Table in the
**
dualport.
Attempts to write beyond the logical size of the
**
device will be rejected, e.g., the caller requests a write of a
**
full rack of data to a device that is a half–rack in size.
**
This example was designed, in part, to demonstrate how the
**
data in the adapter status table may be accessed an used.
**
performance reasons, some applications may perform a block move
**
of data to update multiple adapters.
**
this example provides the user a level of security when addressing
**
the Output Image Table by preventing it from accidentally overwriting
**
another adapter's output image.
**
**
INPUT
**
KTX_DUALPORT far *dp – points to the base of the KTX dualport
**
UYBTE link_address – address of device whose data is to be written
**
IO_BUFFER *io – if successful, I/O data will be copied from this
**
**
**
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 put_output_data (KTX_DUALPORT far *dp, UBYTE link_address, IO_BUFFER *io)
{
int
i, max_xfer_size;
UBYTE
*q;
UBYTE
status = SUCCESS;
ADAPTER_CONFIG_INFO far *p;
/**** Point to the adapter status table ****/
p = &dp–>adapter_status_table[link_address].adapter_config_info;
/**** Validate the input parameters ****/
if (link_address > 127)
return INVALID_ADAPTER_ADDRESS;
max_xfer_size = 2 * (p–>size + 1);
if (io–>count > max_xfer_size)
return ADAPTER_SIZE_OVERLAP;
/**** Return status of adapter to caller ****/
if (!p–>in_scan)
status = ADDRESS_NOT_IN_SCAN_LIST;
else if (!p–>exists)
status = ADAPTER_NONEXISTENT;
/**** Transfer the data
****/
for (i=0; i<io–>count; i++)
dp–>output_image_table[(link_address * 2) + i] = io–>data[i];
return status;
}
put_data.c file
The boundary checking in
this variable into dualport
Appendix B
Programming Examples
For
*/
*/
*/
B-17

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents