]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
Compile, simple regression test (standalone, just watch the numbers).
authorhadaq <hadaq>
Thu, 17 Oct 2002 09:09:35 +0000 (09:09 +0000)
committerhadaq <hadaq>
Thu, 17 Oct 2002 09:09:35 +0000 (09:09 +0000)
-- mm

hadaq/hwship.c
hadaq/hwship.h

index 081607d6049b7337adc74bb37b0ab905b5eee096..e16786851fcfbcc73d29909e36c2b7761ed6aa3d 100644 (file)
@@ -1,4 +1,4 @@
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwship.c,v 6.26 2002-10-17 08:20:41 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwship.c,v 6.27 2002-10-17 09:09:35 hadaq Exp $";
 
 #define _POSIX_C_SOURCE 199309L
 #include <unistd.h>
@@ -51,7 +51,7 @@ static void dumpDbgBufs(const HwShip *my)
                fputc('\n', f);
        }
 
-       close(f);
+       fclose(f);
 }
 
 int conHwShip(HwShip *my, const char *name, const Param *param)
@@ -122,27 +122,39 @@ void HwShip_requestBuffer(HwShip *my)
        my->endOfData = 0;
 }
 
+void HwShip_getEndOfData(HwShip *my)
+{
+       void toDbgBuf(HwShip *my);
+       my->endOfData = LVme_getL(my->lvme, LVL2_OFFSET) - 2 + LVL2_OFFSET;
+       toDbgBuf(my);
+}
+
+#define SHIP_NODATASIZE 0x10
 int HwShip_readSubEvt(HwShip *my, void *subEvt)
 {
-       uint32_t *data = (uint32_t *) subEvt;
-       int firstAddr;
-       size_t size;
+       int readSubEvtR;
+       unsigned long size;
+       unsigned long lastAddr;
 
        assert(my->bankRequested == bankConfirmed(my));
-       assert(endOfData(my) <= LVL2_OFFSET + sizeof(uint16_t) * LVL2_SIZE);
+       assert(my->endOfData > 0);
+       assert(my->endOfData <= LVL2_OFFSET + sizeof(uint16_t) * LVL2_SIZE);
+
        size = LVme_getL(my->lvme, my->currAddr);
+       lastAddr = my->currAddr + size;
+
 #if 0
-       assert(size < sizeof(uint32_t) * 1600); /* whereever the 1600 comes from */
+       assert(size < sizeof(uint32_t) * 0x1600);       /* whereever the 0x1600 comes from */
 #else
        if (my->isDoomed) {
                dumpDbgBufs(my);
                syslog(LOG_EMERG, "%s: was doomed in previous buffer, dump buffer again and abort", my->name);
                abort();
        }
-       if (size >= sizeof(uint32_t) * 1600) {
+       if (size >= sizeof(uint32_t) * 0x1600) {
                dumpDbgBufs(my);
                syslog(LOG_EMERG, "%s: corrupted subEvt, dump buffer and try one more", my->name);
-               my->currAddr = endOfData(my);
+               my->currAddr = my->endOfData;
                my->isDoomed = 1;
                SubEvt_setDecoding(subEvt, 0x00020001);
                SubEvt_setSize(subEvt, 0x10);
@@ -152,11 +164,21 @@ int HwShip_readSubEvt(HwShip *my, void *subEvt)
        }
 #endif
 
-       /* copy one sub evt from RC to memory */
-       for (firstAddr = my->currAddr; my->currAddr - firstAddr < size; my->currAddr += 4) {
-               *data++ = LVme_getL(my->lvme, my->currAddr);
+       if (size <= SHIP_NODATASIZE) {
+               my->currAddr = lastAddr;
+               readSubEvtR = 1;
+               syslog(LOG_DEBUG, "subEvt: empty, skipped");
+       } else {
+               uint32_t *data = (uint32_t *) subEvt;
+
+               /* copy one sub evt from RC to memory */
+               while (my->currAddr < lastAddr) {
+                       *data++ = LVme_getL(my->lvme, my->currAddr);
+                       my->currAddr += 4;
+               }
+               readSubEvtR = 0;
+               syslog(LOG_DEBUG, "subEvt: %s", SubEvt_2charP(subEvt));
        }
 
-       syslog(LOG_DEBUG, "subEvt: %s", SubEvt_2charP(subEvt));
-       return 0;
+       return readSubEvtR;
 }
index df3b9a86a3f33f86b2c7c1237c7b3af81edd406d..c20b33f4572e8bc6acf547ef6e7794cda6eb6864 100644 (file)
@@ -13,6 +13,14 @@ typedef struct HwShipS {
        int currAddr;
        int endOfData;
        int bankRequested;
+       int currDbgBuf;
+       uint32_t dbgBuf0[sizeof(uint16_t) * LVL2_SIZE / sizeof(uint32_t)];
+       uint32_t dbgBuf1[sizeof(uint16_t) * LVL2_SIZE / sizeof(uint32_t)];
+       uint32_t dbgBuf2[sizeof(uint16_t) * LVL2_SIZE / sizeof(uint32_t)];
+       size_t dbgBufLen;
+       uint32_t *dbgBuf[3];
+       int nDbgBufs;
+       int isDoomed;
 }
 
 HwShip;
@@ -35,11 +43,7 @@ static int HwShip_isBufRequested(HwShip *my)
        return my->endOfData == 0;
 }
 
-static void HwShip_getEndOfData(HwShip *my)
-{
-       my->endOfData = LVme_getL(my->lvme, LVL2_OFFSET) - 2 + LVL2_OFFSET;
-       toDbgBuf(my);
-}
+void HwShip_getEndOfData(HwShip *my);
 
 static int bankConfirmed(HwShip *my)
 {