Programming conventions, Programming conventions -2, Dos considerations -2 – Rockwell Automation 1747-PCIS API Software - Open Controller User Manual

Page 24: Dos considerations

Advertising
background image

Publication 1747-UM002A-US-P - June 2000

2-2 Using the API

Programming Conventions

The API is supplied as an object code library file [DOS (

ocapil.lib

)]

or a DLL [NT (

ocapi.dll

)] that you link with the host application’s

object code using commercially-available tools.

DOS Considerations

The DOS API is as consistent as possible with APIs for other operating
system platforms. This makes it easier for you to migrate applications
and it simplifies support. To create a consistent API, careful
consideration was given to these requirements:

This convention:

Considerations:

calling convention

The DOS API functions are specified using the C programming language syntax. To
allow you to develop control applications in other programming languages, the API
functions use the standard Pascal calling convention.
The Windows NT API supports any programming languages that use the Win32 _stdcall
calling convention for application interface functions. The Windows NT API function
names are exported from the DLL in undecorated format to simplify access from other
programming languages.

header files

The API includes a header file (

ocapi.h

) that contains API function declarations,

data structure definitions, and other constant definitions. The header file is in standard
C format.

sample code

The API comes with sample files to provide an example application that communicates
with the scanner. The sample files include all source files and MAKE files required to
build the sample application.

compiler support

The DOS API is supplied in the large memory model, compatible with both Microsoft
and Borland compilers. The DOS library (

ocapil.lib

) is compiled as a 16-bit

MS-DOS library using the 80386 instruction set.
The Windows NT library (

ocapi.dll

) is compiled for use with Microsoft Visual C++

or Borland C++.

This requirement:

Considerations:

memory mapping

The dual port RAM, or shared memory, is mapped automatically at power-up by the PCI bus in the
host processor’s memory address space on any even 8K boundary between 0xC0000 and 0xDFFFF.
For MS-DOS, it is important that any installed memory managers (such as EMM386) or other TSR
software avoid accessing the 8K dual port memory window.
Place the base memory select jumper in 1M position to allow the PCI BIOS to assign a base
memory address.

DOS interrupts

An interrupt is automatically assigned to the scanner by the PCI bus at power-up.

control-break handler

Because communication with the scanner requires memory and interrupt resources (as described
above), improper termination of the host application can leave these resources allocated by the
scanner and unusable by other applications. For this reason the API includes a default
control-break handler.
The default control-break handler is installed by OC_OpenScanner. If you press a

[Ctrl-C]

or

[Ctrl-Break]

key sequence, the following prompt is displayed:

Terminate Application? (Y/N) _
A response of

Y

properly exits the application; a response of

N

causes the application to continue.

If you need a different control-break handler, you must install it after calling the OC_OpenScanner
function. Always call the OC_CloseScanner function before exiting an application.

Advertising
This manual is related to the following products: