-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrich.c,v 6.3 1999-11-01 08:35:36 muench Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrich.c,v 6.4 2000-02-03 18:02:46 muench Stab $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
-#include <string.h>
+#include <string.h>
#include <sys/time.h>
+#define SYNCHRONOUS
+
+#ifdef SYNCHRONOUS
+#include <lvme.h>
+
+#include "dtu_defs.h"
+
+#endif
#include "param.h"
#include "subevt.h"
#include "hwrace.h"
/* Set number of RCs here */
-#define NRACES 1
+#define NRACES 2
struct HardwareS {
size_t maxSubEvtSize;
HwRace *race[NRACES];
unsigned raceToRead;
+#ifdef SYNCHRONOUS
+ LVme *lvme;
+#endif
};
#include "hardware.h"
Hardware *my;
Param paramS, *param = ¶mS;
int i;
+#ifdef SYNCHRONOUS
+ unsigned long cardBase;
+#endif
+
+#ifdef SYNCHRONOUS
+ cardBase = 0x44100000;
+#endif
if (0 > conParam(param, "param.tcl")) {
msglog(LOG_DEBUG, "%s:%d:%s\n", __FILE__, __LINE__, strerror(errno));
}
my = allocMem(sizeof(Hardware));
- my->maxSubEvtSize = SubEvt_hdrSize() + (0x2010 * sizeof(UInt4));
+ my->maxSubEvtSize = SubEvt_hdrSize() + (2500 * sizeof(UInt4));
my->raceToRead = 0;
for (i = 0; i < NRACES; i++) {
}
}
+#ifdef SYNCHRONOUS
+ my->lvme = allocMem(sizeof(LVme));
+ if (-1 == conLVme(my->lvme, cardBase, 0x100000, 0x09, 0, 0)) {
+ return NULL;
+ }
+ /* set Lock Busy */
+ LVme_setBitL(my->lvme, STATUS1, 4);
+#endif
desParam(param);
return my;
desHwRace(my->race[i]);
freeMem(my->race[i]);
}
+#ifdef SYNCHRONOUS
+ desLVme(my->lvme);
+#endif
freeMem(my);
}
void Hardware_waitForTrigger(Hardware *my, void *subEvt)
{
+#ifdef SYNCHRONOUS
+ int i, j;
+ static int beginRun = 1; /* eat 1 triggers at begin run */
+
+ while (beginRun > 0) {
+ /* wait for begin run trigger and release busy afterwards */
+ while (!LVme_tstBitL(my->lvme, STATUS1, 6)) {
+ struct timespec tS, *t = &tS;
+ t->tv_sec = 0;
+ t->tv_nsec = 020000000;
+ nanosleep(t, NULL);
+ }
+ LVme_setL(my->lvme, RELEASE1, 0xee);
+ sleep(1);
+ beginRun--;
+ }
+#endif
if (HwRace_isEmpty(my->race[my->raceToRead])) {
+#ifdef SYNCHRONOUS
+ LVme_setL(my->lvme, RELEASE1, 0xee);
+ for (i = 0; i < 20000; i++) {
+ j = 1 + 1;
+ }
+/* msglog(LOG_INFO, "buffer is empty RC %d\n",my->raceToRead); */
+#endif
HwRace_requestBuffer(my->race[my->raceToRead]);
+#ifdef SYNCHRONOUS
+ for (i = 0; i < 20000; i++) {
+ j = 1 + 1;
+ }
+/* msglog(LOG_INFO, "switch request set\n"); */
+#endif
while (HwRace_isBusy(my->race[my->raceToRead])) {
-#if 1
+#if 0
+/*
+ * This sleep prevents a tight loop which stops work on real
+ * time systems if the priority of readout is not lowered.
+ * When not using the sleep use option -p -2 for daq_readout.
+*/
struct timespec tS, *t = &tS;
t->tv_sec = 0;
t->tv_nsec = 020000000;
void Hardware_readout(Hardware *my, void *subEvt)
{
HwRace_readSubEvt(my->race[my->raceToRead], subEvt);
- if (++my->raceToRead == NRACES ) {
+ if (++my->raceToRead == NRACES) {
my->raceToRead = 0;
}
}
-static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/readout.c,v 6.8 1999-11-22 09:00:48 hades Exp $";
+static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/readout.c,v 6.9 2000-02-03 18:06:04 muench Stab $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
HadTuQueue *hadTuQueue;
Worker_dump(worker, 1);
- hadTu = ShmTrans_alloc(shmTrans, 64 * 1024);
+ hadTu = ShmTrans_alloc(shmTrans, 60 * 1024);
#ifndef NDEBUG
msglog(LOG_DEBUG,
"shmTrans: %p = hadTu: %s\n", hadTu, HadTu_2charP(hadTu));
#endif
hadTuQueue = allocMem(HadTuQueue_sizeOf());
- conHadTuQueue(hadTuQueue, hadTu, 64 * 1024);
+ conHadTuQueue(hadTuQueue, hadTu, 60 * 1024);
while (NULL != (subEvt = HadTuQueue_alloc(hadTuQueue, Hardware_maxSubEvtSize(hw)))) {
Hardware_waitForTrigger(hw, subEvt);