#include <epicsExport.h>
#include <genSubRecord.h>
#include <stringinRecord.h>
+#include <syslog.h>
#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<MAXERRS; i++ ){
+
+ if( (*errbit) & (0x00000001 << errMsgs[i].bit) ){
+ sprintf(msg, "<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);
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);
}