Allen-Bradley 1784-KTX Reference Manual page 102

Table of Contents

Advertisement

/***************************************************************************
**
**
UBYTE bt_write (KTX_DUALPORT far * dp, UBYTE slot_number,
**
**
**
**
This routine instructs the KTX scanner to perform a
**
Block Transfer Write.
**
**
INPUTS
**
KTX_DUALPORT far *dp
**
UBYTE slot_number
**
UBYTE link_address
**
BT_BUFFER *bt_buf
**
UBYTE trans_num
**
USHORT timeout
**
**
OUTPUT
**
UBYTE status
**
***************************************************************************/
#include "ktx_dp.h"
#include "ktx_err.h"
#include "ktxconst.h"
UBYTE bt_write (KTX_DUALPORT far *dp, UBYTE slot_number, UBYTE link_address,
BT_BUFFER *bt_buf, UBYTE trans_num, USHORT timeout)
{
UBYTE
status;
int
i,size;
/**** Initialize the command buffer ****/
dp–>cmd_buffer.host_command = BT_WRITE;
dp–>cmd_buffer.transaction_num = trans_num;
/**** Copy entire BT buffer if length is ****/
/**** set to ADAPTER_DECIDE_LENGTH
if (bt_buf–>count == ADAPTER_DECIDE_LENGTH)
size = 64;
else
size = bt_buf–>count;
dp–>cmd_buffer.command_length = 3 + (2*size);
dp–>cmd_buffer.cmd.bt_write.module_slot_address = slot_number;
/**** Convert link address to logical rack address ****/
dp–>cmd_buffer.cmd.bt_write.logical_rack_address = link_address >> 2;
dp–>cmd_buffer.cmd.bt_write.bt_data_length = bt_buf–>count;
for (i=0; i<size; i++)
dp–>cmd_buffer.cmd.bt_write.bt_data[i] = bt_buf–>bt_data[i];
/**** Send the command ****/
dp–>int_status_from_host = SCANNER_COMMAND_FROM_HOST;
dp–>host_to_ktx_int_reg = INTERRUPT_KTX;
/**** Get and acknowledge the confirmation
status = get_confirmation(dp, trans_num, timeout);
if ((status != CONFIRMATION_TIMED_OUT) && (status != TRANS_NUM_MISMATCH))
acknowledge_confirmation(dp);
return status;
}
bt _write.c file
UBYTE link_address, BT_BUFFER *bt_buf,
UBYTE trans_num, USHORT timeout)
– points to the base of the KTX dualport
– BT module slot number (0–15)
– device link address
– BT data buffer
– transaction_number
– time (in seconds) to wait for completion
– completion status of the command
/* 1784–KTX scanner dualport definition
/* 1784–KTX scanner error codes
/* 1784–KTX scanner constants
****/
****/
Appendix B
Programming Examples
*/
*/
*/
B-23

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents