Sensoray 2410 API User Manual
Page 24

Sensoray 24xx Programming Guide
20
Model 2410 Digital I/O Module
Depending on the message type, additional information may be passed to the callback through
val
, which is a
pointer to the information. In many cases, the information will be an array of three 16-bit words, where each bit is a
boolean that is associated with one DIO channel.
Example:
// A simple callback function that reports capture system events.
void
callback(
char
msgtype,
const
u16 *val )
{
switch
( msgtype )
{
case
CAPMSG_ATTACH:
printf( "first callback\n" );
break
;
case
CAPMSG_DETACH:
printf( "final callback\n" );
break
;
case
CAPMSG_TIMER:
printf( "started timer: %d msec\n", val[0] );
break
;
case
CAPMSG_POLARITY:
printf( "polarities set: %04x %04x %04x\n", val[2], val[1], val[0] );
break
;
case
CAPMSG_CONTINUOUS:
printf( "cont cap enabled: %04x %04x %04x\n", val[2], val[1], val[0] );
break
;
Message Type Code
Description
CAPMSG_ATTACH
The async notification system has been activated. This is always the first message
received by the callback. It can be used to initialize the application’s event handling
system, if desired.
val
is not used and should be ignored.
CAPMSG_DETACH
The async notification system has shut down. This is always the last message received by
the callback. The notification system will shut down if the application calls
s2410_AsyncCapEnd()
or if the connection closes unexpectedly.
val
is not used and
should be ignored.
CAPMSG_POLARITY
Capture polarities have changed as a result of an earlier call to
s2410_WriteCapPolarity()
.
val
points to an array of three words that indicate the new
polarities that are now in effect.
CAPMSG_CONTINUOUS
Continuous capturing has been enabled for an arbitrary set of DIO channels in response to
an earlier call to
s2410_WriteCapContinuous()
.
val
points to an array of three words
that indicate the channels for which continuous capturing has been enabled.
CAPMSG_ONESHOT
One-shot capturing has been enabled for an arbitrary set of DIO channels in response to an
earlier call to
s2410_WriteCapOneShot()
.
val
points to an array of three words that
indicate the channels for which one-shot capturing has been enabled.
CAPMSG_DISABLE
Capturing has been disabled for an arbitrary set of DIO channels in response to an earlier
call to
s2410_WriteCapDisable()
.
val
points to an array of three words that indicate
the channels for which capturing has been disabled.
CAPMSG_EVENT
Events have been captured on one or more DIO channels, or the timer started in an earlier
call to
s2410_AsyncCapTimer()
has timed out.
val
points to an array of three words that
contain event flags for all 48 DIO channels. If one or more flags are set then the
corresponding channels captured edge events. If no flags are set then the timer timed out
before any events were detected.
CAPMSG_TIMER
A timer has started in response to an earlier call to
s2410_AsyncCapTimer()
.
val
points
to a single word that contains the time interval, in milliseconds, that remain until time-out.
CAPMSG_ERROR
The connection closed unexpectedly. One more callback will follow this one, with
message type set to
CAPMSG_DETACH
to indicate that the notification system has shut
down.