4 library linking, 5 required function calls – Sensoray 2600 User Manual

Page 8

Advertising
background image

Sensoray 2600 Programming Guide

4

Fundamentals of Usage

3.3.1 Data Types

Data values passed to or received from library functions belong to a small set of fundamental data types. All custom data types
employed by the API are listed in Table 1. Data types are referenced by their C-language type names, as shown in the left column
of the table.

3.4 Library Linking

3.4.1 Windows

An application that calls functions in

S2600.DLL

must first link to the DLL, and when terminated, an application must unlink from

the DLL so that resources used by the DLL will be released. The means by which DLL linking and unlinking is implemented
depends on your development environment.

Visual Basic: VB applications do not require calls to

S26_DLLOpen()

or

S26_DLLClose()

because they automatically link

when any DLL function is first called, and automatically unlink when the application terminates. Instead, VB applications
must explicitly call

S26_DriverOpen()

and

S26_DriverClose()

when starting and terminating, respectively.

C/C++: applications must call

S26_DLLOpen()

to link to the DLL before calling any of its functions, and

S26_DLLClose()

when the application terminates. Note that these two functions are not part of the DLL; they are provided in the

Win2600.c

module on the distribution media.

Other: If you are using a development tool that does not perform automatic DLL linking, you must create functions

equivalent to

S26_DLLOpen()

and

S26_DLLClose()

as shown in the

Win2600.c

module on the distribution media.

3.4.2 Linux

An application that calls functions in

lib2600.a

must be statically linked to the library when the application is built.

For example, suppose you created a simple C-language program named

app.c

, which you have compiled to produce object file

app.o

. In addition, you have previously located

lib2600.a

in your project directory. You can now execute the following

command line to link the library and produce the

app

executable.

gcc -g -o app app.o -L. -l2600

3.5 Required Function Calls

Some library functions are used universally in all applications, while others, depending on application requirements, may or may
not be used. All applications must, as a minimum, perform the following steps:

1.

Call

S26_DriverOpen()

to initialize the middleware. This should always be the first middleware function executed by a

client application program. Windows only: this is called automatically if you call

S26_DLLOpen()

.

2.

For each MM, call

S26_OpenBoard()

to enable communication with the target MM.

3.

For each MM, call

S26_ResetNetwork()

to initialize the target MM and verify that it is detected, fault-free and ready to

communicate. If more than one Ethernet client will be communicating with the target MM, this function should be called
only once by a designated “master” client ; all other clients should wait until the master has called this function, and then
they are free to communicate with the MM.

4.

For each MM, call

S26_RegisterAllIoms()

to detect and register all I/O modules (IOMs) that are connected to the MM.

5.

To guarantee proper cleanup upon application termination, call

S26_DriverClose()

once. Windows only:

S26_DriverClose()

is called automatically if you call

S26_DLLClose()

.

Table 1: Data types used by library functions

Type Name

Description

u8

8-bit unsigned integer

s16/u16

16-bit signed/unsigned integer

s32/u32

32-bit signed/unsigned integer

Advertising