beautypg.com

Ethernet api reference, Overview, Functions – Measurement Computing Net232 User Manual

Page 11: Ce ……11, Nswinit, Nsessionbegin

background image

Net232 User’s Guide,

1037-0901, rev 2.0

11

Ethernet API Reference

Overview

Users can write their own programs with an ethernet API. The API is provided by two software files:
NPCI_WIN.DLL for 16-bit windows developers, and NPCI_W3V.DLL for 32-bit windows developers.
The only system requirement is that the Windows TCP/IP protocol be loaded and configured.

With a mechanism called session handles, the API can simultaneously handle multiple Net232 units. All functions
rely on the session handle to keep track of the Net232 selected for communication.

A typical session with a Net232 consists of the following basic parts:

Initialization - Initialization requires several functions to be called in appropriate order. These functions include:

nSWInit

, nSessionBegin, nIOLock and nSERIALConfigure.

Actual communications (during the session) - Communication functions include nSerialReceive and

nSerialSend

.

De-initialization – De-initialization is for ending a session, and uses the functions: NSessionEnd and NSWDeinit.

Detailed descriptions of each function are covered in the following section. Examples programs are also included on
the distribution disk.

Functions

nSWInit

Function: int nSwInit(void);
Parameters: None
Returns: 0 if successful, error code if not.

Description: This function is used to allocate system resources prior to beginning a session. This function must be
called before any others.

Example:

ErrVal = nSWInit ();

nSessionBegin

Function: int nSessionBegin (short adapter, char FAR *local, char FAR *remote,

unsigned long flags, unsigned long reserved, long FAR *session);

Parameters:

Short

adapter

Always a 0.

Char FAR *

local

Always a null string.

Char FAR * remote

A null terminated string, which contains the IP address of the Net232.

Unsigned long

flags

Always zero

Unsigned long

reserved

Always zero

Long FAR *

session

A variable used to receive the session handle.

Returns: 0 if successful, error code if not.

Description: This function is used to establish a session with a specific Net232. If a successful connection is made,

then a session handle is assigned and placed in the session argument. Since each session is unique, it is
possible to have multiple sessions active at any given time.

Example:

ErrVal = nSessionBegin(0,”\0”,”192.0.0.1\0”,0,0.session);