Chapter 4. Sample Programs

Table of Contents

4.1. DHPD
4.2. SDSI
4.3. SB
4.4. SDTEST

The sample programs provided with the Administrator are included to provide examples of the use of the DH/DHP interface. The diagnostic programs may be especially useful for understanding the Allen-Bradley diagnostic command system.

Some brief notes about the sample code:

Familiarity with the C language is helpful to understand the code in the sample programs. Some changes to the code may be required to compile the samples with a different compiler or to run it under a different version of the operating system.

The include file sdmsgs.h contains some useful definitions. This file should be included in any C program that sends messages to the administrator.

Some type definitions occasionally have been used to shorten the source code:

typedef unsigned char uchr;
typedef unsigned int uint;
typedef unsigned long ulng;

4.1. DHPD

The sample program, dhpd.c, shows how to open a handle, send various diagnostic commands, monitor diagnostic counters of any Data Highway or Data Highway Plus station and display a list of all active stations on the Data Highway Plus. This program is an excellent example to explore the full functionality of the card and the Administrator. Program syntax is as follows:

dhpd [c=card_num] [n=admin_name] [N=admin_node]

The program is menu-driven and self-explanatory. The executable file can be created by compiling and linking dhpd.c. An extra include file abdh.h is included on the distribution disk to be used with this program.