--- /dev/null
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+#include <dbDefs.h>
+#include <registryFunction.h>
+#include <subRecord.h>
+#include <epicsExport.h>
+#include <genSubRecord.h>
+#include <stringinRecord.h>
+
+#include "worker.h"
+
+int errbitstatDebug;
+
+long errbitstat_init( struct genSubRecord *pgsub )
+{
+ return(0);
+}
+
+long errbitstat_proc( struct genSubRecord *pgsub )
+{
+ uint32_t *out[10];
+ unsigned long tmp;
+ int i;
+
+ out[0] = (uint32_t *)pgsub->vala; /* errbit pattern 0 */
+ out[1] = (uint32_t *)pgsub->valb; /* errbit pattern 1 */
+ out[2] = (uint32_t *)pgsub->valc; /* errbit pattern 2 */
+ out[3] = (uint32_t *)pgsub->vald; /* errbit pattern 3 */
+ out[4] = (uint32_t *)pgsub->vale; /* errbit pattern 4 */
+ out[5] = (uint32_t *)pgsub->valf; /* errbit statistics 0 */
+ out[6] = (uint32_t *)pgsub->valg; /* errbit statistics 1 */
+ out[7] = (uint32_t *)pgsub->valh; /* errbit statistics 2 */
+ out[8] = (uint32_t *)pgsub->vali; /* errbit statistics 3 */
+ out[9] = (uint32_t *)pgsub->valj; /* errbit statistics 4 */
+
+ for( i=0; i<10; i++ )
+ *out[i] = 0;
+
+ char buf[_POSIX_PATH_MAX];
+ sprintf( buf, "%s%s", "daq_evtbuild", getenv("EBNUM") );
+
+ /*
+ * *************** error bit patterns ***************
+ */
+
+ for (i = 0; i < 5; i++) {
+ char name[100];
+ sprintf(name, "errBitPtrn%d", i);
+
+ if( Worker_getStatistic( buf, name, &tmp ) == -1) {
+ *out[i] = 0;
+ if(errbitstatDebug)
+ printf("<E> errbitstat.c: Worker_getStatistic failed for %s!\n", name);
+ }
+ else{
+ *out[i] = (uint32_t)tmp;
+
+ if(errbitstatDebug)
+ printf("<E> errbitstat.c: %s = %lu\n", name, tmp);
+ }
+ }
+
+ /*
+ * *************** nrOfMsgs and status of EB ***************
+ */
+
+ uint32_t nrOfMsgs = 0;
+
+ if( Worker_getStatistic( buf, "nrOfMsgs", &tmp ) == -1) {
+ nrOfMsgs = 0;
+ if(errbitstatDebug)
+ printf("<E> errbitstat.c: Worker_getStatistic failed for nrOfMsgs!\n");
+ }
+ else {
+ nrOfMsgs = (uint32_t)tmp; /* nrOfMsgs */
+ }
+
+ /*
+ * *************** error bit statictics ***************
+ */
+ int j;
+
+ for( i=0; i<5; i++ ){
+ for( j=0; j<nrOfMsgs; j++ ){
+ char name[_POSIX_PATH_MAX];
+ sprintf(name, "errBitStat%d_%d", i, j);
+
+ if( Worker_getStatistic( buf, name, &tmp ) == -1) {
+ *out[i+5] = 0;
+
+ if(errbitstatDebug)
+ printf("<E> errbitstat.c: Worker_getStatistic failed for %s!\n", name);
+ }
+ else {
+ *out[i+5] = (uint32_t)tmp; /* nrOfMsgs */
+
+ if(errbitstatDebug)
+ printf("<E> errbitstat.c: %s = %lu\n", name, tmp);
+
+ out[i+5]++;
+ }
+ }
+ }
+
+return(0);
+}
+
+/* Register these symbols for use by IOC code: */
+
+epicsExportAddress(int, errbitstatDebug);
+epicsRegisterFunction(errbitstat_init);
+epicsRegisterFunction(errbitstat_proc);
+
+