Programming Examples
Appendix B
B-10
ktx_xmpl.c file
/***************************************************************************
**
** FILE KTX_XMPL.C
**
** DESCRIPTION
** This file contains the C functions to demonstrate sending commands
**
to the KTX Scanner and getting the confirmations.
**
** USAGE
**
ktx_xmpl –aXXXX where XXXX is the base hexadecimal address of the KTX.
**
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <conio.h>
#include <time.h>
#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
*/
#define CLOCK_INTR
0x1C
/* Clock interrupt vector
*/
/***************************************************************************
**
**
Global variables
**
***************************************************************************/
KTX_DUALPORT
far
*dp;
/* pointer to KTX dualport
*/
UBYTE
wdg_preset;
/* watchdog timer preset value
*/
UBYTE
wdg_accum;
/* watchdog timer accumulated value
*/
UBYTE
ktx_alive;
/* boolean flag for local loop control */
void interrupt
(*oldhandler)();
/* pointer to old interrupt service routine */
void interrupt
KTX_watchdog();
/* function prototype declaration
*/
/***************************************************************************
**
** int main(int argc, char *argv[])
**
** This routine calls a series of example subroutines which return a
** completion status. No effort is made to examine the status and
** handle unsuccessful commands.
**
***************************************************************************/
int
main (int argc, char *argv[])
{
int
i;
UWORD
segment;
UBYTE
status,
trans_count = 0;
IO_BUFFER out = {8, {0, 1, 2, 3, 4, 5, 6, 7}};
IO_BUFFER in;
BT_BUFFER bt_buffer;
FAULT_GROUP_BYTE fdg[128];
/**** Scan lists: ‘auto_scan_list’ buffers the scan list returned by
***** the autoconfirgure command. ‘expected_scan_list’ is the scan
***** list that should be returned by autoconfigure () if the link is
***** configured properly and all adapters are online. ‘runtime_scan_list’
***** is the scan list that will be used during normal operation. It has
***** duplicate link addresses to demonstrate that some adapters may be
***** scan more often if the application requires it.
****/
SCAN_LIST auto_scan_list;
SCAN_LIST expected_scan_list = {3, {0x04, 0x0E, 0x13}};
SCAN_LIST runtime_scan_list = {4, {0x04, 0x0E, 0x04, 0x13}};
/**** Extract dualport base address from command line ****/