Events can be one of two types: solicited or unsolicited. Solicited events occur when a multitasking function terminates. Unsolicited events are typically generated by an occurrence external to the application, such as a clock error or exceeding error thresholds. Your application should be set up to handle both kinds of events.
The following example illustrates handling unsolicited events such as processing SCX160 clocking alarms:
#include <windows.h>
#include <stdio.h>
#include <srllib.h>
#include <dtilib.h>
#include <scxlib.h>
int ProcessClockAlarms(short ScxDev)
{
unsigned char ClockState;
unsigned char ClockEvent;
unsigned char EventType;
unsigned char *EventDatap;
unsigned short int EventMask;
/* Enable reporting of SCX160 Clock Alarms */
EventMask = SCXMM_SC_CLOCK | SCXMM_SCX_CLOCK | SCXMM_EXT_CLOCK;
if (scx_setevtmsk(ScxDev, EventMask) == -1) {
printf("ERROR: scx_setevtmsk( ) failed: %s (%d)\n",
ATDV_ERRMSGP(ScxDev), ATDV_LASTERR(ScxDev));
return(-1);
}
/* Loop Forever processing SCX160 Clock Alarm Events */
while (1) {
/* Block until an event is retrieved */
sr_waitevt(-1);
/* Wait for a SCX160 Alarm Event - Ignore all other events */
if ((sr_getevtdev( ) != ScxDev) || (sr_getevttype( ) != TSCX_ALARM)) {
continue;
}
/* Perform processing dependent upon the type of the event */
EventDatap = (unsigned char *)sr_getevtdatap( );
EventType = *EventDatap++;
switch (EventType) {
case SCXEV_SCBUS_CLOCK:
printf("SCbus Clock Event Detected\n");
break;
case SCXEV_SCXBUS_CLOCK:
printf("SCxbus Clock Event Detected\n");
break;
case SCXEV_EXT_CLOCK:
printf("SCxbus EXTERNAL Clock Event Detected\n");
break;
default:
printf("Unknown SCX160 Clock Event: 0x%X\n", EventType);
return(-1);
}
/* Determine specific SCX160 Clock Failure/Recovery. */
ClockEvent = *EventDatap;
if (ClockEvent & SCXST_CLK_RECOVER) {
printf("Recovery of ");
}
switch (ClockEvent) {
case SCXST_SCX_RCLOCK:
printf("SCX160 SCxbus Right Clock Failure\n");
break;
case SCXST_SCX_LCLOCK:
printf("SCX160 SCxbus Left Clock Failure\n");
break;
case SCXST_SC_CLOCK:
printf("SCX160 SCbus Clock Failure\n");
break;
case SCXST_SC_CLOCK_FAIL_SIG:
printf("SCX160 SCbus Clock Fail Signal\n");
break;
case SCXST_EXTCLOCK:
printf("SCX160 SCxbus External Clock Failure\n");
break;
case SCXST_PLL_REF:
printf("SCX160 PLL Reference Failure\n");
break;
case SCXST_INTCLOCK:
printf("SCX160 Internal Clock Failure\n");
break
}
/* Display the current status of all SCbus/SCxbus Clocks */
if (scx_getbrdparm(ScxDev, SCXBP_CLK_STATE_BYTE, (void *)&ClockState) == -1) {
printf("ERROR: scx_getbrdparm( ) failed: %s (%d)\n",
ATDV_ERRMSGP(ScxDev), ATDV_LASTERR(ScxDev));
return(-1);
}
printf("\nCurrent State of SCbus/SCxbus Clocks:\n");
printf(" SCX160 SCxbus Right Clock: %s\n",
(ClockState & SCXST_SCX_RCLOCK) ? "FAIL" : "OKAY");
printf(" SCX160 SCxbus Left Clock: %s\n",
(ClockState & SCXST_SCX_LCLOCK) ? "FAIL" : "OKAY");
printf(" SCX160 SCbus Clock: %s\n",
(ClockState & SCXST_SC_CLOCK) ? "FAIL" : "OKAY");
printf(" SCX160 SCbus Clock Fail Signal: %s\n",
(ClockState & SCXST_SC_CLOCK_FAIL_SIG) ? "FAIL" : "OKAY");
printf(" SCX160 SCxbus External Clock: %s\n",
(ClockState & SCXST_EXTCLOCK) ? "FAIL" : "OKAY");
printf(" SCX160 PLL Reference: %s\n",
(ClockState & SCXST_PLL_REF) ? "FAIL" : "OKAY");
printf(" SCX160 Internal Clock: %s\n",
(ClockState & SCXST_INTCLOCK) ? "FAIL" : "OKAY");
} /* End of WHILE */
return(0);
}
Click here to contact Dialogic Customer Engineering
Copyright 2001, Dialogic Corporation