ms_getevt( )
Cautions | Errors | Example | See Also
Name: int ms_getevt (devh, eblkp, timeout) Inputs:
Returns: Includes: Category: Mode: Platform: Description
The ms_getevt( ) function is supported under Windows only. It blocks and returns control to the application for a specified event. This happens after one of the unsolicited events set by ms_setevtmsk( ) occurs on the station device specified by the devh parameter or if a timeout occurs.
devh the valid device handle returned by a call to ms_open( ) evtblkp pointer to the event that ended the blocking timeout the maximum amount of time to wait for an event to occur. If timeout is set to -1, the ms_getevt( ) function does not timeout and blocks until an event occurs. If timeout is set to 0 and an event is not present, the function returns immediately with a -1 return code. On successful return from the function, the event block structure, EV_EBLK, will have the following information:
- ev_dev
- The device on which the event occurred. This is the same as the devh passed to the function.
- ev_event
- MSEV_SIGEVT indicating signaling transition event.
- ev_data
- An array of bytes where ev_data[0] and ev_data[1] contain the signaling information. Signaling information is retrieved in short variable. Refer to the example below for information on retrieving this data.
The event block structure is defined as follows:
typedef struct ev_eblk { int ev_dev; /* Device on which event occurred */ unsigned long ev_event; /* Event type */ int ev_len; /* Length of data associated with event */ unsigned char ev_data[8]; /* 8 byte data buffer */ void ev_datap; /* variable pointer if more than 8 bytes of data */ } EV_EBLK;Cautions
- The ms_getevt( ) function is not supported under the Linux operating system.
- This function fails when:
Errors
If this function returns -1 to indicate failure, obtain the reason for the error by calling the SRL standard attribute function ATDV_LASTERR( ) or ATDV_ERRMSGP( ) to retrieve either the error code or a pointer to the error description, respectively.
Refer to the error type tables found in Chapter 5, "Error Codes". Error defines can be found in dtilib.h or msilib.h.
Example
#include <windows.h> #include <errno.h> #include "srllib.h" #include "dtilib.h" #include "msilib.h" EV_EBLK eblk; main() { int devh; /* Board device handle */ unsigned short sigmsk = MSMM_ONHOOK | MSMM_OFFHOOK | MSMM_HOOKFLASH; short sig; /* * Open station 1 device */ if ((devh = ms_open("msiB1C1",0)) == -1) { printf("Error: Cannot open board 1 station 1. errno = 0x%x\n",errno); exit(1); } if (ms_setevtmsk(devh, MSEV_SIG, sigmsk, DTA_SETMSK) == -1) { printf("%s: ms_setevtmsk MSEV_SIGMSK DTA_SETMSK ERROR %d: %s:Mask = 0x%x\n", ATDV_NAMEP(devh),ATDV_LASTERR(devh),ATDV_ERRMSGP(devh),sigmsk); ms_close(devh); exit(1); } /* * Wait for events on this time slot */ while(1) { ms_getevt ( devh, &eblk, -1 ); /* Wait forever */ if (eblk.ev_event == MSEV_SIGEVT) { sig = eblk.ev_data[0] | (short) eblk.ev_data[1] << 8 ; if ((sig & MSMM_ONHOOK) == MSMM_ONHOOK) printf("Onhook signal received\n"); if ((sig & MSMM_OFFHOOK) == MSMM_OFFHOOK) printf("Offhook signal received\n"); if ((sig & MSMM_HOOKFLASH) == MSMM_HOOKFLASH) printf("Hook flash signal received\n"); } } /* end of while statement */ }See Also
Click here to contact Telecom Support Resources
Copyright 2003, Intel Corporation