{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<MAXERRS; i++ ){
-
- if( (*errbit) & (0x00000001 << errMsgs[i].bit) ){
- sprintf(msg, "<I> errbit: %d msg: %s", errMsgs[i].bit, errMsgs[i].msg);
-
+ if( errbit & (0x00000001 << errMsgs[i].bit) ){
+ sprintf(msg, "EB%s <E> 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;
}
}
}
else{
*out[i] = (uint32_t)tmp;
-
- /* ERRBITLOG = 0/1 (log via syslog (off/on))*/
- if(getenv("ERRBITLOG")){
- errbit2logger((uint32_t)tmp);
- }
-
- if(errbitstatDebug)
- printf("<E> errbitstat.c: %s = %lu\n", name, tmp);
}
}
* *************** 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<nrOfMsgs; j++ ){
else {
*out[i+5] = (uint32_t)tmp; /* nrOfMsgs */
- if(errbitstatDebug)
- printf("<E> 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: */