beautypg.com

3 session initialization and shutdown – Sensoray 2410 API User Manual

Page 13

background image

Sensoray 24xx Programming Guide

9

Module-Independent Functions

5.3 Session Initialization and Shutdown

5.3.1 s24xx_SessionOpen()

Function:

Open a communication session with an I/O module.

Prototype:

BOOL s24xx_SessionOpen( HSESSION *sess, u32 *err, u16 model, const char *addr, u16 port, u32 ms );

Returns:

True if the operation was successful, otherwise False is returned and

err

will contain the associated error code.

Notes:

After opening a session for an I/O module, the application may use the session handle in all other functions that
require it.

Example:

See section 5.4.1.

5.3.2 s24xx_SessionClose()

Function:

Terminate a communication session with an I/O module.

Prototype:

void s24xx_BoardClose( HSESSION sess );

Returns:

None.

Notes:

Each session that has been established by

s24xx_SessionOpen()

must be closed when it is no longer needed by

an application.

s24xx_SessionClose()

severs the communication link between the application program and the

I/O module. The session handle is no longer valid after this call.

s24xx_SessionClose()

does not alter the state of the module and the module will continue any autonomous

operations already in progress. Since all communications will be severed between the client and the module, the
application should ensure that all I/O interfaces are in appropriate states when

s24xx_SessionClose()

is called.

Example:

See section 5.4.1.

Argument

Description

sess

Pointer to storage that will receive the session handle. The target storage will be set to
zero if a session failed to open.

err

Pointer to error code. See Section 4.3.1 for details.

model

Model number of the I/O module (e.g., 2410, 2426, etc.)

addr

Pointer to a null-terminated string that specifies the I/O module’s IP address in dotted
decimal format.

port

Telnet port number used by the I/O board. Use the standard telnet port number (23)
unless the board has been reconfigured to use a non-standard port number.

ms

Maximum amount of time to wait (in milliseconds) for the session to be established.
This can be relatively short for dedicated LANs, but longer times may be needed if
the I/O board is remotely located.

Argument

Description

sess

Session handle obtained from

s24xx_SessionOpen()

.