From ca31871ac4fb342ad8f4b67afd9ae95bbaacaa3b Mon Sep 17 00:00:00 2001 From: hadaq Date: Thu, 17 Oct 2002 09:09:35 +0000 Subject: [PATCH] Compile, simple regression test (standalone, just watch the numbers). -- mm --- hadaq/hwship.c | 50 ++++++++++++++++++++++++++++++++++++-------------- hadaq/hwship.h | 14 +++++++++----- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/hadaq/hwship.c b/hadaq/hwship.c index 081607d..e167868 100644 --- a/hadaq/hwship.c +++ b/hadaq/hwship.c @@ -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 @@ -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; } diff --git a/hadaq/hwship.h b/hadaq/hwship.h index df3b9a8..c20b33f 100644 --- a/hadaq/hwship.h +++ b/hadaq/hwship.h @@ -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) { -- 2.43.0