4 network utilities – Sensoray Smart A/D User Manual

Page 6

Advertising
background image

S

ENSORAY

I

NSTRUCTION

M

ANUAL

S

MART

A/D D

RIVER

FOR

W

INDOWS

Page 4

4.

Call GetFaultFlags() to verify that the board is properly initialized, fault-free and registered with the driver.

5.

For each channel, call SetSensorType() to declare the sensor type to be interfaced.

3.4 Network Utilities

This section is applicable if you are using Networking Smart A/D™ boards.

Network IP addresses are typically specified and manipulated at the user-interface level in

dotted decimal notation. For

example, the text string value “135.135.135.127” is much easier to use by a human operator than is 2273806207, the
equivalent numerical value. As evidence of this, consider the classic “Ping” utility, which accepts IP addresses only in dotted
decimal notation for ease of use.

In order to provide a standardized format for all Smart A/D™ boards, physical addresses that are passed to or from the driver
must be specified as integer values. To support the need for both the user-friendly dotted decimal address and the
driver-required integer address formats, the driver includes two utilities that translate between these IP address representations,
InetAtoN()

and InetNtoA(), which are described in this section. These are the only driver functions that do not require a

board handle parameter. A board handle is not required because these functions do not reference a specific board.

3.4.1 InetAtoN()

Function:

Converts an IP “dot address” text string into a host byte-ordered integer IP address. This function can be used to
convert an IP address from the “user-friendly” dot address form to the integer value that is required by many of the
other driver functions.

Prototype:

long InetAtoN( char *dotadrs );

Example:

/////////////////////////////////////////////////////////////////////////////

// Convert the IP Address 135.135.135.24 to its equivalent numerical value.

/////////////////////////////////////////////////////////////////////////////

char dotadrs[] = “135.135.135.24”;

long ipadrs = InetAtoN( dotadrs );

3.4.2 InetNtoA()

Function:

Converts a host byte-ordered integer IP address to “dot address” form. This function can be used to convert an IP
address from the integer form used by many driver functions to a “user-friendly” dot address string.

Prototype:

void InetNtoA( char *dotadrs, long ipadrs );

Example:

///////////////////////////////////////////////////////////////////////////

// Get the IP address of board number 0 in dot address form.

///////////////////////////////////////////////////////////////////////////

char dotadrs[16];

long ipadrs = InetNtoA( dotadrs, GetBoardAdrs(0) );

Parameter

Type

Description

dotadrs

char*

Address of a buffer that contains an IP address expressed in the “dot address” format.

return value

long

Equivalent host byte-ordered integer IP address.

Parameter

Type

Description

dotadrs

char*

Address of a buffer that will receive the “dot address” string.

ipadrs

long

Host byte-ordered binary IP address.

Advertising