Allen-Bradley 1784-KTX Reference Manual page 95

Table of Contents

Advertisement

Appendix B
Programming Examples
/***************************************************************************
**
**
UBYTE
initialize_KTX (KTX_DUALPORT far *dp, UBYTE link_baud_rate,
**
**
**
This routine initializes the KTX.
**
has already been downloaded into the card.
**
**
PARAMETERS
**
KTX_DUALPORT far *dp –
**
UBYTE link_baud_rate –
**
USHORT timeout
**
**
***************************************************************************/
#include <time.h>
#include <stdlib.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
UBYTE
initialize_KTX (KTX_DUALPORT far *dp, UBYTE link_baud_rate,
USHORT timeout)
{
int
i;
UBYTE
status;
time_t
t0;
UBYTE
boot_code[] = {0xC3, 0, 0, 0};
/**** Initialize dualport variables ****/
for (i = 0; i < sizeof(boot_code); i++ )
dp–>boot_code[i] = boot_code[i];
dp–>link_address = SCANNER_LINK_ADDRESS;
dp–>link_protocol = KTX_SCANNER_PROTOCOL;
dp–>link_baud_rate = link_baud_rate;
/**** Start the KTX & timer ****/
dp–>assert_reg = TRUE;
t0 = time(NULL);
/**** Wait for completion ****/
while (dp–>int_status_to_host != INIT_DONE_INTERRUPT) {
if ((time(NULL) – t0) > timeout) {
status = INITIALIZATION_TIMED_OUT;
break;
}
}
/**** If not a timeout, return completion status ****/
if (status != INITIALIZATION_TIMED_OUT)
status = dp–>init_status;
return status;
}
Allen-Bradley Parts
B-16
init_ktx.c file
USHORT timeout)
It assumes the 1784–KTX binary
points to the base of the KTX dualport
desired baud rate: 57.6, 115.2, or 230.4
time (in seconds) to wait for KTX to
complete initialization.
*/
*/
*/

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents