From 124536fb3f6b848dc562a660e156d98e362badce Mon Sep 17 00:00:00 2001 From: hadaq Date: Fri, 25 Mar 2011 17:24:11 +0000 Subject: [PATCH] Added logging for error bits. Sergey. --- ebctrl/ioc/ebctrlApp/src/errbitstat.c | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/ebctrl/ioc/ebctrlApp/src/errbitstat.c b/ebctrl/ioc/ebctrlApp/src/errbitstat.c index 004857e..0992af9 100644 --- a/ebctrl/ioc/ebctrlApp/src/errbitstat.c +++ b/ebctrl/ioc/ebctrlApp/src/errbitstat.c @@ -12,11 +12,60 @@ #include #include #include +#include #include "worker.h" int errbitstatDebug; +#define MAXERRS 11 + +typedef struct TheErrMsgS { + int bit; + char msg[200]; +} TheErrMsg; + +TheErrMsg errMsgs[] = { + {16, "Event number mismatch"}, + {17, "Trigger code mismatch"}, + {18, "Wrong length"}, + {19, "Answer missing"}, + {20, "Requested event number does not match stored event number"}, + {21, "Parts of data are missing"}, + {22, "Severe problem"}, + {23, "Single broken event"}, + {24, "Ethernet link broken"}, + {26, "Ethernet error"}, + {27, "Timing trigger error"} }; + +static void errbit2logger( const uint32_t *errbit ) +{ + int i; + char msg[250]; + static time_t t0 = 0; + time_t t, dT; + + t = time(NULL); + dT = t - t0; + + /* ERRBITWAIT = wait time in seconds */ + if(dT > getenv("ERRBITWAIT")){ + + for( i=0; i errbit: %d msg: %s", errMsgs[i].bit, errMsgs[i].msg); + + openlog("DAQ", LOG_ODELAY, LOG_LOCAL1); + syslog(LOG_INFO, msg); + closelog(); + } + } + + t0 = t; + } +} + long errbitstat_init( struct genSubRecord *pgsub ) { return(0); @@ -61,6 +110,11 @@ 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); } -- 2.43.0