-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>
fputc('\n', f);
}
- close(f);
+ fclose(f);
}
int conHwShip(HwShip *my, const char *name, const Param *param)
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);
}
#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;
}
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;
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)
{