Sensoray 2410 API User Manual
Page 23

Sensoray 24xx Programming Guide
19
Model 2410 Digital I/O Module
u16 flags[3];
if
( !s2410_ReadCapFlags( sess, &err, flags ) )
printf( "Error: %s\n", s24xx_ErrorText(err) );
else
printf( "Events: %04x %04x %04x\n", flags[2], flags[1], flags[0] );
6.4.3 s2410_AsyncCapBegin()
Function:
Enable asynchronous notifications for capture system events.
Prototype:
HEVCAP s2410_AsyncCapBegin( const char *addr, u32 *err, u16 port, EVENT_CBK callback, u32 msec );
Returns:
Handle to asynchronous notification system. This will be non-zero if the operation was successful, otherwise
NULL is returned and
err
will contain the associated error code.
Notes:
s2410_AsyncCapBegin()
activates a notification system that will asynchronously call an application function (a
“callback”) in response to various events that occur on the module. A new, private session is opened on the module
to support the notification system. Consequently, a free session must be available on the module when this function
is called.
When the notification system is activated, the callback function will be called once with message type
CAPMSG_ATTACH
(see section 6.4.3.1 for message types) to inform the application that the notification system has
activated.
Example:
// Activate asynchronous event notifications.
u32 err = ERR_NONE;
if
( !s2410_AsyncCapBegin( "192.168.24.10", &err, 23, callback, 5000 ) )
printf( "Error: %s\n", s24xx_ErrorText(err) );
6.4.3.1 Callback Function
Function:
Application callback that handles asynchronous notifications from the event capture system.
Prototype:
void callback( char msgtype, const u16 *val );
Notes:
The callback function executes in the context of a private thread. Each time it is called, it receives a message type
code that indicates the nature of the notification. Messages are received in the order they were produced so that the
application can synchronize to the capture system state machine.
Argument
Description
addr
Pointer to a null-terminated string that specifies the I/O module’s IP address.
err
Pointer to error code. See Section 4.3.1 for details.
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.
callback
Pointer to the application’s callback function. See section 6.4.3.1 for details.
msec
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
msgtype
Message type code.
val
Pointer to additional information that depends on the message
type.