
3–6 Developing Applications
Publication 1747-6.5.3 June 1998
Programming
Example for DOS
The following DOS example (sample.c on your API disk) shows how to program
the above steps. Callouts on the right margin identify the code for each step.
/************************************************************************
*
* FILE:sample.c
*
* PURPOSE:Sample application code for 1746 I/O PCI Interface API
*
* SUMMARY:This program,
* - Resets and initializes the scanner.
* - Displays the scanner firmware and hardware versions.
* - Autconfigures the I/O in chassis.
* - Reads the front panel switch position and lights LED 1.
* - Reads first discrete input module data word.
* - Writes incremental data to first output module data word.
* - Closes connection to scanner and exits.
*
* ENVIRONMENT:1747-PCIS 1746 I/O PCI Interface
* MS-DOS
* Borland/Microsoft C/C++ Compiler (16-bit)
*
************************************************************************/
/*=======================================================================
= INCLUDE FILES =
=========================================================================*/
#include ”ocapi.h”
#include <stdio.h>
#include <dos.h>
#include <time.h>
#include <conio.h>
#include <string.h>
/*=======================================================================
= MODULE WIDE GLOBAL VARIABLES =
=========================================================================*/
HANDLE Handle; /* Software ID to scanner device */
OCIOCFG OCcfg; /* Chassis I/O config. data structure */
/*=======================================================================
= FUNCTION PROTOTYPES =
=========================================================================*/
void Ioexit( int );
/*=======================================================================
= MAIN PROGRAM =
=========================================================================*/
void main()
{
int retcode; /* Return code from API calls */
int i;
int slots;
int input_slot, input_found = 0;
int output_slot, output_found = 0;
OCINIT ocpart;
BYTE status;
OCVERSIONINFO verinfo;
BYTE swpos;
WORD wData;
Komentarze do niniejszej Instrukcji