int errbitstatDebug;
#define MAXERRS 11
+#define ERRBITLOG 0
+#define ERRBITWAIT 30
typedef struct TheErrMsgS {
int bit;
{26, "Ethernet error"},
{27, "Timing trigger error"} };
+static int env2int(char *envName)
+{
+ /*
+ * Convert Epics environment variable (ascii to int)
+ */
+ int retVal = 0;
+ char *envVar;
+
+ if(! strcmp(envName, "ERRBITLOG")){
+ envVar = getenv(envName);
+
+ if(envVar == NULL){
+ retVal = ERRBITLOG;
+
+ if(errbitstatDebug)
+ printf("<E> errbitstat.c: env var %s is not set! Default to %i\n", envName, retVal);
+ }
+ }
+ else if(! strcmp(envName, "ERRBITWAIT")){
+ envVar = getenv(envName);
+
+ if(envVar == NULL){
+ retVal = ERRBITWAIT;
+
+ if(errbitstatDebug)
+ printf("<E> errbitstat.c: env var %s is not set! Default to %i\n", envName, retVal);
+ }
+ }
+ else{
+ if(errbitstatDebug)
+ printf("<E> errbitstat.c: env var %s is not known! Default to %i\n", envName, retVal);
+ }
+
+ return retVal;
+}
+
static void errbit2logger( const uint32_t errbit, const uint32_t errbitstat, int nrOfErrWord, const int subsys )
{
int i, j;
* ERRBITLOG = 0/1 (log via syslog (off/on))
* ERRBITWAIT = wait time in seconds
*/
- if(atoi(getenv("ERRBITLOG")) && ((int)dT > atoi(getenv("ERRBITWAIT")))){
+ if(env2int("ERRBITLOG") && ((int)dT > env2int("ERRBITWAIT"))){
errbit2logger(*out[i], *out[i+5], i, j);
t0 = t;
}