Allen-Bradley 1784-KTX Reference Manual page 58

Table of Contents

Advertisement

Chapter 5
Issuing Block Transfer Commands
#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 bt_read (KTX_DUALPORT far *dp, UBYTE slot_number, UBYTE link_address, BT_BUFFER *bt_buf,
{
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);
break;
/* if an error occurred, acknowledge the confirmation */
/* and return the status to the caller
default:
acknowledge_confirmation(dp);
break;
}
return status;
}
5-8
Example 5.B
UBYTE trans_num, USHORT timeout)
****/
*/
*/
*/
*/
*/

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents