]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
new version: suppresses headers if no data are delivered. WK
authorhadaq <hadaq>
Sun, 19 May 2002 23:17:03 +0000 (23:17 +0000)
committerhadaq <hadaq>
Sun, 19 May 2002 23:17:03 +0000 (23:17 +0000)
hadaq/hwtip.c

index a7b4ead0fe68a05cedb6827f1836e6f2e237b7c1..18f1b7c1d68e51b89c93ad94be579b456b4f0be1 100644 (file)
@@ -1,4 +1,4 @@
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwtip.c,v 1.21 2001-11-18 11:56:21 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwtip.c,v 1.22 2002-05-19 23:17:03 hadaq Exp $";
 
 #include <assert.h>
 #include <string.h>
@@ -104,6 +104,7 @@ static int endOfData(HwTip * my)
        return LVme_getL(my->lvme, my->fifo) + my->fifo;
 }
 
+#define TIP_BUFSIZE 0x40000
 int conHwTip(HwTip * my, const char *name, const Param *param)
 {
        unsigned long cardBase;
@@ -134,7 +135,7 @@ int conHwTip(HwTip * my, const char *name, const Param *param)
        my->pipeFull = _LVL2_PIPE2_FULL;
        my->daqRq = _LVL2_PIPE2_RQ;
        my->daqGr = _LVL2_PIPE2_GR;
-       my->fifo = MEMBASE + 0x40000;
+       my->fifo = MEMBASE + TIP_BUFSIZE;
 
        return 0;
 }
@@ -163,7 +164,7 @@ void HwTip_requestBuffer(HwTip * my)
                my->pipeFull = _LVL2_PIPE2_FULL;
                my->daqRq = _LVL2_PIPE2_RQ;
                my->daqGr = _LVL2_PIPE2_GR;
-               my->fifo = MEMBASE + 0x40000;
+               my->fifo = MEMBASE + TIP_BUFSIZE;
        } else {
                my->bankRequested = 0;
                my->pipeFull = _LVL2_PIPE1_FULL;
@@ -186,24 +187,27 @@ int HwTip_isEmpty(HwTip * my)
 {
        return my->currAddr >= endOfData(my);
 }
-
+#define TIP_NODATASIZE 20
 int HwTip_readSubEvt(HwTip * my, void *subEvt)
 {
        uint32_t *data = (uint32_t *) subEvt;
-       int firstAddr;
+       int lastAddr;
        size_t size;
 
        size = LVme_getL(my->lvme, my->currAddr);
-       if (size > 0x40000) {
+       lastAddr = my->currAddr + size;
+       if (size > TIP_BUFSIZE) {
          syslog(LOG_ERR, "found size: %.8x , address: %.8x, too long, fatal! ", size, my->currAddr);
-         exit(1);
+         my->currAddr = lastAddr;
+         return -1;
+       }
+       if( size <= TIP_NODATASIZE ) {
+               my->currAddr = lastAddr;
+               return 1;
        }
        /* copy one sub evt from RC to memory */
-       firstAddr = my->currAddr;
-       /* take the size from above to use the check */
        *data++ = size;
-       my->currAddr += 4;
-       for (; my->currAddr - firstAddr < size; my->currAddr += 4) {
+       while ((my->currAddr+=4) < lastAddr) {
          *data++ = LVme_getL(my->lvme, my->currAddr);
        }