kindof working t203 timer

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@114 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Anthony Minessale 2007-05-23 19:47:35 +00:00
parent fe0bbb8396
commit 0ca281c3a9
2 changed files with 32 additions and 3 deletions

View File

@ -131,7 +131,7 @@ int Q921QueueHDLCFrame(L2TRUNK trunk, L2UCHAR *b, L2INT size);
int Q921Rx12(L2TRUNK trunk);
int Q921Rx32(L2TRUNK trunk, L2UCHAR * Mes, L2INT Size);
int Q921Start(L2TRUNK trunk);
void Q921SetGetTimeCB(L2ULONG (*callback)());
void Q921TimerTick(L2TRUNK trunk);
void Q921SetGetTimeCB(L2ULONG (*callback)());
void Q921TimerTick(L2TRUNK trunk);
#endif

View File

@ -35,9 +35,26 @@
#include "zap_isdn.h"
#include "Q931.h"
#include "Q921.h"
#ifdef WIN32
#include <windows.h>
#else
#include <sys/time.h>
#endif
#define LINE "--------------------------------------------------------------------------------"
#define IODEBUG
static L2ULONG zap_time_now()
{
#ifdef WIN32
return timeGetTime();
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return ((tv.tv_sec * 1000) + (tv.tv_usec / 1000));
#endif
}
static L3INT zap_isdn_931_err(void *pvt, L3INT id, L3INT p1, L3INT p2)
{
zap_log(ZAP_LOG_ERROR, "ERROR: %d %d %d", id, p1, p2);
@ -93,6 +110,10 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
unsigned char buf[1024];
zap_size_t len = sizeof(buf);
#ifdef WIN32
timeBeginPeriod(1);
#endif
zap_log(ZAP_LOG_DEBUG, "ISDN thread starting.\n");
Q921Start(&data->q921);
@ -100,7 +121,9 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
while(zap_test_flag(data, ZAP_ISDN_RUNNING)) {
zap_wait_flag_t flags = ZAP_READ;
zap_status_t status = zap_channel_wait(data->dchan, &flags, 100);
Q921TimerTick(&data->q921);
switch(status) {
case ZAP_FAIL:
{
@ -144,6 +167,10 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
zap_channel_close(&data->dchans[1]);
zap_clear_flag(span->isdn_data, ZAP_ISDN_RUNNING);
#ifdef WIN32
timeEndPeriod(1);
#endif
zap_log(ZAP_LOG_DEBUG, "ISDN thread ended.\n");
return NULL;
}
@ -151,6 +178,8 @@ static void *zap_isdn_run(zap_thread_t *me, void *obj)
zap_status_t zap_isdn_init(void)
{
Q931Initialize();
Q921SetGetTimeCB(zap_time_now);
return ZAP_SUCCESS;
}