From: hadaq Date: Mon, 4 Apr 2011 10:43:51 +0000 (+0000) Subject: Errbit logging via syslog finilized. Sergey. X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=3e064165cbaf2f428ec3662d20eb6255eb6e196a;p=daqdata.git Errbit logging via syslog finilized. Sergey. --- diff --git a/ebctrl/ioc/ebctrlApp/src/errbitstat.c b/ebctrl/ioc/ebctrlApp/src/errbitstat.c index 0992af9..6294e02 100644 --- a/ebctrl/ioc/ebctrlApp/src/errbitstat.c +++ b/ebctrl/ioc/ebctrlApp/src/errbitstat.c @@ -38,31 +38,39 @@ TheErrMsg errMsgs[] = { {26, "Ethernet error"}, {27, "Timing trigger error"} }; -static void errbit2logger( const uint32_t *errbit ) +static void errbit2logger( const uint32_t errbit, const uint32_t errbitstat, int nrOfErrWord, const int subsys ) { - int i; + int i, j; char msg[250]; - static time_t t0 = 0; - time_t t, dT; - - t = time(NULL); - dT = t - t0; + static uint32_t statOld[5][100]; /* 5 error words, 100 data sources */ + static int initStatOld = 0; + + /* Init array to zero at the beginning */ + if(initStatOld == 0){ + for( i=0; i<5; i++ ){ + for( j=0; j<100; j++ ){ + statOld[i][j] = 0; + } + } + initStatOld = 1; + } - /* ERRBITWAIT = wait time in seconds */ - if(dT > getenv("ERRBITWAIT")){ + /* + * If errBitStatistics increased... + */ + if(errbitstat != statOld[nrOfErrWord][subsys]){ for( i=0; i errbit: %d msg: %s", errMsgs[i].bit, errMsgs[i].msg); - + if( errbit & (0x00000001 << errMsgs[i].bit) ){ + sprintf(msg, "EB%s subsys: %i errbit: %d msg: %s", getenv("EBNUM"), subsys, errMsgs[i].bit, errMsgs[i].msg); + openlog("DAQ", LOG_ODELAY, LOG_LOCAL1); syslog(LOG_INFO, msg); closelog(); } } - t0 = t; + statOld[nrOfErrWord][subsys] = errbitstat; } } @@ -109,14 +117,6 @@ long errbitstat_proc( struct genSubRecord *pgsub ) } else{ *out[i] = (uint32_t)tmp; - - /* ERRBITLOG = 0/1 (log via syslog (off/on))*/ - if(getenv("ERRBITLOG")){ - errbit2logger((uint32_t)tmp); - } - - if(errbitstatDebug) - printf(" errbitstat.c: %s = %lu\n", name, tmp); } } @@ -139,6 +139,11 @@ long errbitstat_proc( struct genSubRecord *pgsub ) * *************** error bit statictics *************** */ int j; + static time_t t0 = 0; + time_t t, dT; + + t = time(NULL); + dT = t - t0; /* delta Time for logging error statistics */ for( i=0; i<5; i++ ){ for( j=0; j errbitstat.c: %s = %lu\n", name, tmp); + /* + * ERRBITLOG = 0/1 (log via syslog (off/on)) + * ERRBITWAIT = wait time in seconds + */ + if(atoi(getenv("ERRBITLOG")) && ((int)dT > atoi(getenv("ERRBITWAIT")))){ + errbit2logger(*out[i], *out[i+5], i, j); + t0 = t; + } out[i+5]++; } } } -return(0); + return(0); } /* Register these symbols for use by IOC code: */