Allen-Bradley 1784-KTX Reference Manual page 103

Table of Contents

Advertisement

Appendix B
Programming Examples
/***************************************************************************
**
**
UBYTE bt_read (KTX_DUALPORT far * dp, UBYTE slot_number,
**
**
**
**
This routine instructs the KTX scanner to perform a Block Transfer
**
Read.
**
**
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_read (KTX_DUALPORT far *dp, UBYTE slot_number, UBYTE link_address,
{
int
i;
UBYTE
status;
/**** Initialize the command buffer ****/
dp–>cmd_buffer.host_command = BT_READ;
dp–>cmd_buffer.transaction_num = trans_num;
dp–>cmd_buffer.command_length = 3;
dp–>cmd_buffer.cmd.bt_read.module_slot_address = slot_number;
/**** Convert the link address to logical rack address ****/
dp–>cmd_buffer.cmd.bt_read.logical_rack_address = link_address >> 2;
dp–>cmd_buffer.cmd.bt_read.bt_data_length = bt_buf–>count;
/**** Send the command ****/
dp–>int_status_from_host = SCANNER_COMMAND_FROM_HOST;
dp–>host_to_ktx_int_reg = INTERRUPT_KTX;
/**** Get and process the confirmation
status = get_confirmation(dp, trans_num, timeout);
switch (status) {
/* break if no confirmation was available */
case CONFIRMATION_TIMED_OUT:
break;
/* break if the transaction numbers didn't match */
case TRANS_NUM_MISMATCH:
break;
/* when successful, copy BT read data to caller
/* and acknowledge the confirmation
case SUCCESS:
bt_buf–>count = dp–>confirmation_buffer.conf_length/2;
for (i=0; i < bt_buf–>count; i++)
bt_buf–>bt_data[i] = dp–>confirmation_buffer.conf.bt_read.bt_data[i];
acknowledge_confirmation(dp);
Allen-Bradley Parts
break;
B-24
bt _read.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 which is to be written on
completion of the BT
– 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
BT_BUFFER *bt_buf, UBYTE trans_num, USHORT timeout)
****/
*/
*/
*/
*/

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents