-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>
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;
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;
}
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;
{
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);
}