
Description | Cautions | Example | Errors | See Also
Name: |
int dx_sendevt(dev, evttype, evtdatap, evtlen, flags) | |
Inputs: |
int dev |
|
long evttype |
| |
void *evtdatap |
| |
short evtlen |
Length of the data block in bytes | |
unsigned short flags |
SENDSELF/SENDOTHERS/SENDALL | |
Returns: |
0 if successful | |
-1 error return code | ||
Includes: |
dxxxlib.h srllib.h | |
Mode: |
Synchronous | |
The dx_sendevt( ) function allows Inter-Process Event Communication. The event type parameter evttype and its associated data are sent to one or all processes that have the dev parameter device opened. The block pointed to by evtdatap cannot be greater than 256 bytes and hence evtlen cannot contain a number smaller than 0 and bigger than 256. The evtdatap parameter can be NULL and the evtlen parameter 0 if there is no data associated with an event type. The flags parameter determines which processes are going to receive this event. The following values are valid for the flags parameter:
Parameter |
Description |
EVFL_SENDSELF |
/*Only the process calling dx_sendevt( ) will receive the event*/ |
EVFL_SENDOTHERS |
/*All processes that have the device opened except the process calling dx_sendevt( ) will receive the event */ |
EVFL_SENDALL |
/*All processes that have the device opened will receive the event.*/ |
The events generated by this function can be retrieved using sr_waitevt( ), by registering an event handler via sr_enbhdlr( ), or by calling dx_getevt( ) to catch the event if the evttype is set to TDX_CST.
The application can define the evttype and evtdata to be any values as long as evttype is greater than 0x1FFFFFF and less than 0x7FFFFFF0. The only exception to this rule is the use of this function to stop dx_wtring( ) and dx_getevt( ) by sending TDX_CST events. To unblock a process waiting in dx_wtring( ) or dx_getevt( ), send an event of type TDX_CST to that process. The evtlen will be the size of DX_CST structure and evtdatap will point to a DX_CST structure with cst.cst_event set to DE_STOPRINGS or DE_STOPGETEVT as the case may be.
This function will fail if an invalid device handle is specified. No event will be generated if event type value is greater than 0x7FFFFFF0.
#include "srllib.h"
#include "dxxxlib.h"
int dev; /* Dialogic device handle */
DX_CST cst; /* TDX_CST event data block */
/* Open board 1 channel 1 device */
if ((dev = dx_open("dxxxB1C1", 0)) == -1) {
/* Perform system error processing */
exit(1);
}
/* Set up DX_CST structure */
cst.cst_event = DE_STOPGETEVT;
cst.cst_data = 0;
/* Send the event to all other processes that have dxxxB1C1 open */
if (dx_sendevt(dev, TDX_CST, &cst, sizeof(DX_CST), EVFL_SENDOTHERS) == -1) {
printf("Error message = %s", ATDV_ERRMSGP(dev));
exit(1);
}
If the function returns -1 to indicate an error, use the SRL Standard Attribute function ATDV_LASTERR( ) to obtain the error code or you can use ATDV_ERRMSGP( ) to obtain a descriptive error message. The error codes returned by ATDV_ERRMSGP( ) are:
Equate: |
Returned When: |
EDX_BADPARM |
Invalid parameter |
EDX_SYSTEM |
Error from operating system; use dx_fileerrno( ) to obtain error value |
Click here to contact Dialogic Customer Engineering
Copyright 2002, Dialogic Corporation