beautypg.com

Chapter 3: fundamentals of usage, 1 board addressing, 2 thread-safety – Sensoray 2600 User Manual

Page 7: 3 programming examples

background image

Sensoray 2600 Programming Guide

3

Fundamentals of Usage

Chapter 3: Fundamentals of Usage

3.1 Board Addressing

3.1.1 MM Handles

Each Model 2601 board—which is also referred to as a main module, or simply MM—is assigned a reference number called a
handle. A handle is the logical address of a MM. Many of the middleware functions include the MM handle as an argument so
that the function calls will be directed to a specific MM. The first MM is assigned the handle value 0. MM handles are numbered
sequentially up to the value

N-1

, where

N

is the number of MMs in the system.

MM handles are not OS-allocated handles in the traditional sense, but rather are integer values that are assigned by the application
program. When a MM is first declared to the middleware by the application program, any valid, unused handle may be specified
for that MM. Once a handle has been assigned to a MM, it must not be used by any other MM.

3.1.2 IP Address

In addition to the MM handle, which is the logical address for a MM, each MM also has a physical address. The physical address
is the Internet Protocol (IP) address at which the MM resides. A MM’s physical address must always be specified to the
middleware in dotted decimal form (e.g., “

192.168.3.35

”).

3.1.2.1 Setting the MM’s IP Address

A Windows utility program,

cfg2601.exe

, is supplied on the distribution media. This program enables you to examine and

change a MM’s IP address. Follow these steps to program the MM’s IP address:

1.

Turn off power to the target MM.

2.

Attach a null modem cable from the MM’s COM4 connector to any available comport on a PC.

3.

Execute the utility program by typing “

CFG2601 x

” where

x

is the comport being used on the PC. For example, type

cfg2601 2

” if COM2 is being used on the PC.

4.

Wait until the program informs you that it is waiting for the 2601 to be reset.

5.

Apply power to the MM.

6.

Using the program’s menu system, you may examine and change the MM’s IP address.

It is strongly recommended that you assign IP addresses that are specifically reserved for private networks, such as

10.X.X.X

or

192.168.X.X

, to the MMs in your system.

3.2 Thread-Safety

With few exceptions, all middleware functions are thread-safe. Applications should be designed such that the thread-unsafe
functions will not be re-entered while in use by other threads or processes. This is usually not difficult to achieve in practice as
unsafe functions are associated with middleware initialization and shutdown.

3.3 Programming Examples

The C programming language has been used to code all programming examples. In most cases the programming examples can be
easily adapted to other languages.

Many of the examples specify symbolic constants that are defined in

App2600.h

, which can be found on the distribution media.