Programming Examples
Appendix B
B-22
autoconf.c file
/***************************************************************************
**
**
UBYTE autoconfigure (KTX_DUALPORT far *dp, UBYTE trans_num,
**
USHORT timeout)
**
**
This routine instructs the KTX scanner to perform an
**
autoconfiguration and waits for a confirmation. An autoconfigure
**
command requires the scanner to poll all 128 possible device
**
addresses on the RIO link, which can take as long as 6 seconds
**
when operating at 57.6 Kbaud.
**
**
INPUTS
**
KTX_DUALPORT far *dp
– points to the base of the KTX dualport
**
UBYTE trans_num
– transaction_number
**
USHORT timeout
– time (in seconds) to wait for completion
**
**
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
autoconfigure (KTX_DUALPORT far *dp, UBYTE trans_num, USHORT timeout)
{
UBYTE status;
/**** Initialize the command buffer ****/
dp–>cmd_buffer.host_command = AUTOCONFIG;
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 acknowledge the confirmation ****/
status = get_confirmation(dp, trans_num, timeout);
if ((status != CONFIRMATION_TIMED_OUT) && (status != TRANS_NUM_MISMATCH))
acknowledge_confirmation(dp);
return status;
}