
Description | Cautions | Example | Errors | See Also
Name: |
int dt_getevt(devh,eblkp,timeout) (Windows only) | |
Inputs: |
int devh |
|
EV_EBLK *eblkp |
| |
int timeout |
| |
Returns: |
0 on success | |
Includes: |
srllib.h | |
Category: |
Parameter Request | |
Mode: |
Synchronous | |
This dt_getevt( ) function blocks and returns control to the program after one of the events set by dt_setevtmsk( ) occurs on the channel specified in the devh parameter, or a timeout occurs. dt_getevt( ) is used with multi-threaded applications only.
Parameter |
Description |
devh: |
Specifies the valid digital network interface time slot device handle returned by a call to dt_open( ) |
*eblkp: |
Points to the Event Block Structure DX_EBLK, which will contain the event that ended the blocking |
timeout: |
Specifies the maximum amount of time in seconds to wait for an event to occur. timeout can have one of the following values:
|
On successful return from the function the event block structure will have the following information.
eblk.ev_dev: |
Device on which the event occurred - this will be the same as the devh parameter passed in. |
eblk.ev_event: |
DTEV_SIG indicates signaling transition event. |
eblk.ev_data[ ]: |
DTEV_SIG contains information about the signaling event. ev_data[ ] is an array of bytes where ev_data[0] and ev_data[1] contain the signaling information. Retrieve the signaling information in a short variable and see the example below to get the signaling information from ev_data[0] and ev_data[1]. DTEV_T1ERRC contains information about the type of alarm occurring. |
The event block structure is defined as follows:
typedef struct ev_eblk {
long ev_dev; /* Device on which event occurred */
unsigned long ev_event; /* Event type */
long ev_len; /* Length of data associated with event */
char ev_data[8]; /* 8 byte data buffer */
void * ev_datap; /* Variable pointer if more than 8 bytes of
data */
} EV_EBLK;
dt_getevt( ) is only used for multithreaded applications.
#include <windows.h>
#include <srllib.h>
#include <dtilib.h>
#include <errno.h>
EV_EBLK eblk;
main()
{
int devh; /* Board device handle */
unsigned short bitmaskp; /* Bitmask variable */
unsigned short sigmsk = DTMM_AON | DTMM_AOFF | DTMM_BON | DTMM_BOFF;
short sig, indx;
/*
* Open Timeslot 1 device
*/
if ( ( devh = dt_open( "dtiB1T1", 0 ) ) == -1 ) {
printf( "Cannot open timeslot dtiB1T1. errno = %d", errno );
exit( 1 );
}
if (dt_setevtmsk(ddd, DTG_SIGEVT, sigmsk, DTA_SETMSK) == -1) {
printf("%s: dt_setevtmsk DTG_SIGEVT DTA_SETMSK ERROR %d: %s: Mask =
0x%x\n",ATDV_NAMEP(ddd),ATDV_LASTERR(ddd),ATDV_ERRMSGP(ddd),sigmsk);
dt_close(ddd);
exit(1);
}
/*
* Wait for events on this timeslot
*/
while(1) {
dt_getevt ( devh, &eblk, -1 ); /* Wait for ever */
sig = eblk.ev_data[0] | ( (short) eblk.ev_data[1] << 8 );
for (indx = 0; indx <4; indx++) {
if (!(sig & (0x1010 << indx))) {
continue;
}
switch (sig & (0x1111 << indx)) {
case DTMM_AOFF:
fprintf(stderr,"A-OFF ");
break;
case DTMM_AON:
fprintf(stderr,"A-ON ");
break;
case DTMM_BOFF:
fprintf(stderr,"B-OFF ");
break;
case DTMM_BON:
fprintf(stderr,"B-ON ");
break;
} /* End of switch Statement */
} /* end of for statement */
} /* end of while statement */
.
.
.
}
If the function returns -1, use the SRL Standard Attribute function ATDV_LASTERR( ) to obtain the error code or use ATDV_ERRMSGP( ) to obtain a descriptive error message. The error codes returned by ATDV_LASTERR( ) are:
Equate |
Returned When |
EDT_BADPARM |
Invalid parameter |
EDT_SYSTEM |
Windows system error |
EDT_TMOERR |
Timed out waiting for reply from firmware |
Click here to contact Dialogic Customer Engineering
Copyright 2001, Dialogic Corporation