Chapter 4
Issuing Scanner Management Commands
4-6
Example 4.B
#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 set_scan_list (KTX_DUALPORT far *dp, SCAN_LIST *sl,
UBYTE *orphan, UBYTE trans_num, USHORT timeout)
{
UBYTE
status;
/**** Initialize the command buffer ****/
dp–>cmd_buffer.host_command = SET_SCAN_LIST;
dp–>cmd_buffer.transaction_num = trans_num;
dp–>cmd_buffer.command_length = 1 + sl–>count;
dp–>cmd_buffer.cmd.set_scan_list = *sl;
/**** 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;
/* If an adapter became a FDG orphan, copy
*/
/* orphan’s address to caller.
*/
/* (fall through to acknowledge confirmation) */
case SCAN_LIST_CAUSES_FDG_ORPHAN:
*orphan = dp–>confirmation_buffer.conf.set_list.orphan;
acknowledge_confirmation(dp);
break;
/* if a different error occurred or SUCCESS, acknowledge */
/* the confirmation and return the status to the caller */
case SUCCESS:
default:
acknowledge_confirmation(dp);
break;
}
return status;
}