コード例 #1
0
/**
 * Function:  zarlinkAlarmHandle()
 *
 * Description: This function is called at a periodic rate to perform all
 * required API operations.  It implements the functional requirements of the
 * application mentioned in the header.
 */
static void zarlinkAlarmHandle(unsigned long args)
{
    int deviceNum;
    bool deviceEventStatus = FALSE;
    VpEventType pEvent;

	/*
 	 * This loop will query the FXS device for events, and when an event is
	 * found (deviceEventStatus = TRUE), it will parse the event and perform
	 * further operations.
	 */
    for (deviceNum = 0; deviceNum < gDevNum; deviceNum++) {

        VpApiTick(RTKDevList[deviceNum]->pDevCtx, &deviceEventStatus);

		RTKDevList[deviceNum]->UpdIOState(RTKDevList[deviceNum]->pLine[0]);

        if(deviceEventStatus == TRUE) {
            while(VpGetEvent(RTKDevList[deviceNum]->pDevObj, &pEvent)) {
            	/*
 				 * If the event was a Response:Device Init Complete event,
 				 * we need to initialize the device and associated lines, so
				 * send the event structure (pointer) to the Init function for
				 * handling.
				 */
                if (pEvent.eventCategory == VP_EVCAT_RESPONSE) {
                    if(pEvent.eventId == VP_DEV_EVID_DEV_INIT_CMP) {
                        //InitQuickStartSettings(&pEvent);
                    } else if (pEvent.eventId == VP_LINE_EVID_RD_OPTION) {
                        //InitReadOptions(&pEvent);
                    } else {
                        /* Do nothing */
                    }
                    /* We're initializing if a response event occurred. */
                    return;
                }
                //ProcessFXSEvent(&pEvent);
            }
        }
    }

    return;
}
コード例 #2
0
ファイル: sys_service.c プロジェクト: jameshilliard/prism
static void sys_service_tick_handler()
{
	unsigned char deviceId;
	unsigned long flags;
	vpapi_event *pEvent;
#if !defined(ZARLINK_SLIC_VE792)
	bool eventStatus;
#endif
	sigset_t mask;


	pthread_mutex_lock(&vp_lock);

	for(deviceId = 0; deviceId < MAX_DEVICES; deviceId++) {

		

		if(GET_DEV_STATUS(deviceId) == 0)
			continue;

		/* Check for free resources */
		if(event_count >= MAX_EVENT_QUEUE_SIZE)
			goto timer_exit;



#if !defined(ZARLINK_SLIC_VE792)
		if(VP_STATUS_SUCCESS == VpApiTick(&pDevCtx[deviceId], &eventStatus)) {
			if(eventStatus == TRUE) {
#endif
				pEvent = &event_queue[next_event];

				while(VpGetEvent(&pDevCtx[deviceId], &pEvent->vp_event) == TRUE) {

					if(pEvent->vp_event.status != VP_STATUS_SUCCESS) {
						printf("%s: bad status(%d)\n", __func__, pEvent->vp_event.status);
						break;
					}

					if(pEvent->vp_event.eventId == 0)  {
						printf("%s: warning, empty event\n", __func__);
						break;
					}
					next_event++;
					if(next_event == MAX_EVENT_QUEUE_SIZE) {
						next_event = 0;
					}

					event_count++;
					if(pEvent->valid == 0) {
						pEvent->valid = 1;
					}
					else {
						printf("%s: error, event(%u) was overrided\n", __func__, next_event);
						break;
					}

					pEvent = &event_queue[next_event];
				}
#if !defined(ZARLINK_SLIC_VE792)
			}
		}
#endif
	}

	pthread_mutex_unlock(&vp_lock);

	return;

timer_exit:
	return;
}
コード例 #3
0
/*
*****************************************************************************
** FUNCTION:   zarlinkWaitForEvent
**
** PURPOSE:    Waiting for specific event category and event Id on device.
**
** PARAMETERS: deviceNum - Device number of SLIC
**             category  - Event Category to wait for
**             event     - Event Id to wait for
**
** RETURNS:    TRUE  - Event occurred.
**             FALSE - Event did not occur. 
**
*****************************************************************************
*/
static BOOL zarlinkWaitForEvent( VpDevCtxType* pDevCtx, VpEventCategoryType category, uint16 event)
{
   int i;
   VpStatusType status;
   bool vpApiEventPending = FALSE;
   
   for (i = 0; i<SLIC_INIT_TIMEOUT; i++)
   {
      status = VpApiTick( pDevCtx, &vpApiEventPending );
      if (  (status == VP_STATUS_SUCCESS) && 
			(TRUE == vpApiEventPending) )
      {
         VpEventType pEvent;
         while(VpGetEvent(pDevCtx, &pEvent)) 
         {
            switch (pEvent.eventCategory) 
            {
               /* Add more categories as needed */
               case VP_EVCAT_RESPONSE:
                  switch(pEvent.eventId)
                  {
                     /* Add more events as needed */
                     case VP_DEV_EVID_DEV_INIT_CMP:
                        PRINT_MSG("SLIC: Received VP_DEV_EVID_DEV_INIT_CMP event (i = %d)\n", i);
						//InitQuickStartSettings(&pEvent);
                        break;
                     case VP_LINE_EVID_LINE_INIT_CMP:
                        PRINT_MSG("SLIC: Received VP_LINE_EVID_LINE_INIT_CMP event (i = %d)\n", i);
                        break;
                     case VP_EVID_CAL_CMP:
                        PRINT_MSG("SLIC: Received VP_EVID_CAL_CMP event (i= %d)\n", i);
                        break;
					 case VP_LINE_EVID_RD_OPTION:
                        PRINT_MSG("SLIC: Received VP_LINE_EVID_RD_OPTION event (i= %d)\n", i);
                    	//InitReadOptions(&pEvent);
						//EventMaskReady = 1;
						break;
                     default: 
                        /* Do nothing */
						#ifdef DEBUG_API
                        PRINT_MSG("SLIC: ERROR Unexpected Event %d came from the SLIC.\n", pEvent.eventId);
						#endif
                        break;
                  }
                  break;

               default:
                  break;
            }

            /* As soon as it finds the event we are looking for, return */
            if ( (pEvent.eventCategory == category) && (pEvent.eventId == event) )
            {
				#ifdef DEBUG_API
               	PRINT_MSG("SLIC: Found event: pEvent.eventCategory = %d pEvent.eventId = %d \n", 
							pEvent.eventCategory, pEvent.eventId);
				#endif
               return  TRUE;
            }
            else
            {
				#ifdef DEBUG_API
               	PRINT_MSG("SLIC: Unexpected event: pEvent.eventCategory = %d pEvent.eventId = %d \n", 
							pEvent.eventCategory, pEvent.eventId);
				#endif
            }
         }
      }

      mdelay(10);
   }
    
   /* Could not find any events if we reach here */
   return FALSE;
}
コード例 #4
0
ファイル: vpapi_dev.c プロジェクト: HuxyUK/xpenology-3.x
static void vpapi_tick_handler(unsigned long data)
{
	u8 deviceId;
	unsigned long flags;
	vpapi_event *pEvent;
#if !defined(CONFIG_ZARLINK_SLIC_VE792)
	bool eventStatus;
#endif

	/* Check if events are already active and not processing IOCTL */
	if((atomic_read(&vpapi_init) == 0) || (atomic_read(&vpapi_in_ioctl) == 1))
		goto timer_exit;

	spin_lock_irqsave(&vpapi_lock, flags);

	for(deviceId = 0; deviceId < MAX_DEVICES; deviceId++) {

		if(GET_DEV_STATUS(deviceId) == 0)
			continue;

		/* Check for free resources */
		if(atomic_read(&event_count) >= MAX_EVENT_QUEUE_SIZE)
			goto timer_exit;

#if !defined(CONFIG_ZARLINK_SLIC_VE792)
		if(VP_STATUS_SUCCESS == VpApiTick(&pDevCtx[deviceId], &eventStatus)) {
			if(eventStatus == TRUE) {
#endif
				pEvent = &event_queue[next_event];
				while(VpGetEvent(&pDevCtx[deviceId], &pEvent->vp_event) == TRUE) {
					if(pEvent->vp_event.status != VP_STATUS_SUCCESS) {
						printk("%s: bad status(%d)\n", __func__, pEvent->vp_event.status);
						break;
					}

					if(pEvent->vp_event.eventId == 0)  {
						printk("%s: warning, empty event\n", __func__);
						break;
					}

					next_event++;
					if(next_event == MAX_EVENT_QUEUE_SIZE) {
						next_event = 0;
					}

					atomic_inc(&event_count);

					if(pEvent->valid == 0) {
						pEvent->valid = 1;
					}
					else {
						printk("%s: error, event(%u) was overrided\n", __func__, next_event);
						break;
					}

					pEvent = &event_queue[next_event];
				}
#if !defined(CONFIG_ZARLINK_SLIC_VE792)
			}
		}
#endif
	}


	spin_unlock_irqrestore(&vpapi_lock, flags);

timer_exit:

	/* Checks if user application should be signaled */
	if(atomic_read(&event_count) > 0) {
		wake_up_interruptible(&vpapi_wait);
	}

	/* Schedule next timer tick */
	vpapi_timer.expires = jiffies + VPAPI_TICK_TIMER_PERIOD;
	add_timer(&vpapi_timer);
}