beautypg.com

4 error functions, 1 s24xx_errortext() – Sensoray 2410 API User Manual

Page 14

background image

Sensoray 24xx Programming Guide

10

Module-Independent Functions

5.4 Error Functions

5.4.1 s24xx_ErrorText()

Function:

Return an error description string.

Prototype:

const char * s24xx_ErrorText( u32 err );

Returns:

Pointer to a text string that describes the error code contained in

err

.

Example:

// A simple application program.

int

main( void )

{

int

rtnval = 1;

u32 err = ERR_NONE;

char

ipaddr[] = "192.168.24.10"

HSESSION sess

;

// Open the API.

if

( !s24xx_ApiOpen() )

printf( "Failed to open API\n" );

else

{

// Open a session on a Model 2410 I/O module.

if

( !s24xx_SessionOpen( &sess, &err, 2410, ipaddr, 23, 1000 ) ) {

printf( "Error: %s\n", s24xx_ErrorText(err) );
rtnval = err;
}

else

{

// ... perform I/O operations as required by the application ...

s24xx_SessionClose( sess );

// Close the session and API.

}
s24xx_ApiClose();
}

return

rtnval;

}

Argument

Description

err

Error code. See Section 4.3.3 for list of error codes.