beautypg.com

6 timestamp functions, 3 s24xx_getversioninfo(), 1 s24xx_readtimestamp() – Sensoray 2410 API User Manual

Page 16

background image

Sensoray 24xx Programming Guide

12

Module-Independent Functions

u32 err = ERR_NONE;

if

( !s24xx_ResetIo( sess, &err ) )

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

5.5.3 s24xx_GetVersionInfo()

Function:

Read a module’s firmware version information.

Prototype:

BOOL s24xx_GetVersionInfo( HSESSION sess, u32 *err, char *buf, u32 len, BOOL *secondary );

Returns:

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

err

will contain the associated error code.

Example:

// Fetch and display firmware version info.

char buf[100];
BOOL secondary;
u32 err = ERR_NONE;

if

( !s24xx_GetVersionInfo( sess, &err, buf, sizeof(buf), &secondary ) )

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

else

printf( "Firmware version: %s (%s)\n", buf, secondary ? "secondary" : "primary" );

5.6 Timestamp Functions

Every I/O module maintains an independent clock that is used to timestamp data returned by various API functions. The clock
starts at zero upon module boot-up or reset and then increments every microsecond. The 32-bit clock overflows (i.e., restarts at
zero) approximately every 71.5 minutes.

5.6.1 s24xx_ReadTimestamp()

Function:

Read module’s system time.

Prototype:

BOOL s24xx_ReadTimestamp( SESSION sess, u32 *err, u32 *timestamp );

Returns:

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

err

will contain the associated error code.

Example:

// Read and display the current timestamp.

u32 err = ERR_NONE;
u32 systime;

if

( !s24xx_ReadTimestamp( sess, &err, ×tamp ) )

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

else

printf( "Timestamp = %d microseconds\n", timestamp );

Argument

Description

sess

Session handle obtained from

s24xx_SessionOpen()

.

err

Pointer to error code. See Section 4.3.1 for details.

buf

Pointer to buffer that will receive version number string. Set to NULL if string is not
needed.

len

Size of buffer that will receive the version number string. Set to zero if not needed.

secondary

Pointer to buffer that receives indication that secondary firmware is executing. Set to
NULL if not needed. If not NULL, the buffer will be set to False if the factory-installed
base firmware is running, or True if upgraded firmware is running.

Argument

Description

sess

Session handle obtained from

s24xx_SessionOpen()

.

err

Pointer to error code. See Section 4.3.1 for details.

timestamp

Pointer to buffer that will receive the module’s system time.