Allen-Bradley 1784-KTX Reference Manual page 106

Table of Contents

Advertisement

/***************************************************************************
**
**
UBYTE get_scan_list (KTX_DUALPORT far *dp, SCAN_LIST *sl,
**
**
**
This routine instructs the KTX scanner to return the current
**
scan list.
**
**
INPUT
**
KTX_DUALPORT far *dp
**
SCAN_LIST *sl
**
**
UBYTE trans_num
**
USHORT timeout
**
**
OUTPUT
**
UBYTE status
**
***************************************************************************/
#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_scan_list (KTX_DUALPORT far *dp, SCAN_LIST *sl,
UBYTE trans_num, USHORT timeout)
{
int
i;
UBYTE
status;
/**** Initialize the command buffer ****/
dp–>cmd_buffer.host_command = GET_SCAN_LIST;
dp–>cmd_buffer.transaction_num = trans_num;
dp–>cmd_buffer.command_length = 0;
/**** 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 the scan list to the
/* caller and acknowledge the confirmation
case SUCCESS:
sl–>count = dp–>confirmation_buffer.conf.get_list.count;
for (i=0; i<sl–>count; i++)
sl–>scan_list[i] =
dp–>confirmation_buffer.conf.get_list.scan_list[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;
}
getscanl.c file
UBYTE trans_num, USHORT timeout)
– points to the base of the KTX dualport
– if successful, the scan list will be
assigned to this variable
– transaction_number
– time (in seconds) to wait for
– completion status of the command
*/
*/
****/
*/
*/
*/
Appendix B
Programming Examples
B-27

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents