-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwship.c,v 6.19 2002-04-19 19:15:16 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwship.c,v 6.20 2002-05-23 16:53:27 hadaq Exp $";
#include <assert.h>
#include <string.h>
#include <allParam.h>
-#include "ipc_basis.h"
#include "hwship.h"
-static int bankRequested(HwShip *my) {
- return my->bankRequested;
-}
-
-static int bankConfirmed(HwShip *my) {
- uint16_t val;
-
- val = LVme_tstBitL(my->lvme, LVL2_ACCESS_VMEREG, 7);
- return val;
-}
-
-static int endOfData(HwShip *my) {
- return (LVme_getL(my->lvme, LVL2_OFFSET) - 2 + LVL2_OFFSET);
-}
-
int conHwShip(HwShip * my, const char *name, const Param *param)
{
unsigned long cardBase;
/* Select VME-accessible register of LVL2-controller */
LVme_setW(my->lvme, LVL2_SEL_VMEREG, LVL2_SELMEM_VMEREG);
- my->trigNr = 0;
my->currAddr = 0x7fffffff; /* behind end of memory */
+ my->endOfData = 0;
return 0;
}
LVme_setL(my->lvme, LVL2_ACCESS_VMEREG, i);
my->bankRequested = i;
my->currAddr = LVL2_DATASTART;
-}
-int HwShip_isBusy(HwShip *my) {
- return bankRequested(my) != bankConfirmed(my);
+ /* to indicate a buffer request state which is cleared by getEndOfData */
+ my->endOfData =0;
}
-int HwShip_isEmpty(HwShip *my) {
- return my->currAddr >= endOfData(my);
-}
+#define SHIP_NODATASIZE 16
-int HwShip_readSubEvt(HwShip *my, void *subEvt) {
- uint32_t *data = (uint32_t *)subEvt;
+int HwShip_readSubEvt(HwShip *my, void *subEvt)
+{
+ uint32_t * data = (uint32_t *)subEvt;
int lastAddr;
- size_t size;
+ int currAddr = my->currAddr;
+ int size;
+
+ size = LVme_getL(my->lvme, currAddr);
+ lastAddr = currAddr + size;
+ my->currAddr = lastAddr;
+
+ /* skip empty subevent, nobody will realize this */
+ if (size <= SHIP_NODATASIZE) return 1;
- size = LVme_getL(my->lvme, my->currAddr);
- lastAddr = my->currAddr + size;
/* copy one sub evt from RC to memory */
*data++ = size;
- while ((my->currAddr+=4) < lastAddr) {
- *data++ = LVme_getL(my->lvme, my->currAddr);
+ while ((currAddr+=4) < lastAddr) {
+ *data++ = LVme_getL(my->lvme, currAddr);
}
#ifndef NDEBUG