Allen-Bradley 1784-KTX Reference Manual page 89

Table of Contents

Advertisement

Appendix B
Programming Examples
/***************************************************************************
**
**
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
/***************************************************************************
**
**
**
***************************************************************************/
KTX_DUALPORT
far
UBYTE
wdg_preset;
UBYTE
wdg_accum;
UBYTE
ktx_alive;
void interrupt
(*oldhandler)();
void interrupt
KTX_watchdog();
/***************************************************************************
**
**
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.
***** list that should be returned by autoconfigure () if the link is
***** configured properly and all adapters are online.
***** is the scan list that will be used during normal operation.
***** 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 ****/
Allen-Bradley Parts
if ((argc != 2) || (strncmp(argv[1],"–a",2) && strncmp(argv[1],"–A",2))) {
printf("\Usage: ktxexmpl –aXXXX\n");
B-10
ktx_xmpl.c file
/* Clock interrupt vector
Global variables
*dp;
/* pointer to KTX dualport
/* watchdog timer preset value
/* watchdog timer accumulated value
/* boolean flag for local loop control
/* pointer to old interrupt service routine
/* function prototype declaration
'expected_scan_list' is the scan
'runtime_scan_list'
*/
*/
*/
*/
It has
*/
*/
*/
*/
*/
*/

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents