-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrich.c,v 6.26 2002-10-15 12:40:23 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrich.c,v 6.27 2002-10-15 16:27:24 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
}
if (strcmp(subsystem, "unknown") == 0) {
- syslog(LOG_NOTICE, "Subsystem not set, defaulting to rich0");
ss = "rich0";
+ syslog(LOG_NOTICE, "Subsystem not set, defaulting to %s", ss);
} else {
ss = subsystem;
}
-
+
if (0 > conParam(param)) {
- syslog(LOG_ERR, "%s:%d:%s", __FILE__, __LINE__, strerror(errno));
+ syslog(LOG_ERR, "Construction of parameter source failed: %s", strerror(errno));
return NULL;
}
-
if (0 > getCards(param, ss, "race", &nCards, cards)) {
syslog(LOG_ERR, "Retrieval of card list failed");
return NULL;
}
-
my = malloc(sizeof(Hardware));
- my->race = malloc(nCards * sizeof(HwRace));
+ my->race = malloc(nCards * sizeof(HwRace *));
my->lInt = malloc(nCards * sizeof(LInt));
my->maxSubEvtSize = SubEvt_hdrSize() + (nCards * 2500 * sizeof(uint32_t));
for (i = 0; i < my->nRaces; i++) {
unsigned long statusId;
int paramWasFound;
-
+
my->race[i] = malloc(sizeof(HwRace));
if (0 > conHwRace(my->race[i], cards[i], param)) {
- syslog(LOG_ERR, "%s:%d:%s", __FILE__, __LINE__, strerror(errno));
+ syslog(LOG_ERR, "Construction of card %s failed:%s", cards[i], strerror(errno));
return NULL;
}
my->lInt[i] = malloc(sizeof(LInt));
}
for (i = 0; i < my->nRaces; i++) {
- if(HwRace_isBufRequested(my->race[i])) {
+ if (HwRace_isBufRequested(my->race[i])) {
LInt_wait(my->lInt[i]);
HwRace_getEndOfData(my->race[i]);
#ifndef NDEBUG
void Hardware_readout(Hardware *my, void *partEvt)
{
int i;
+ int firstRace = -1;
void *subEvt = SubEvt_data(partEvt);
static uint32_t trigNr = 0;
uint32_t trigTag;
- int firstRace;
int size;
/* init partial event, necessary for SubEvt_next() */
SubEvt_setId(partEvt, 0);
/* read all races, check for common trigger tag */
- firstRace = -1;
for (i = 0; i < my->nRaces; i++) {
- if((size=HwRace_readSubEvt(my->race[i], subEvt)) > 0) {
- if (firstRace < 0) {
- trigTag = SubEvt_trigNr(subEvt) & 0xff;
- firstRace = i;
- } else {
- if (trigTag != (SubEvt_trigNr(subEvt) & 0xff)) {
- SubEvt_setId(subEvt, SubEvt_id(subEvt) | 0x80000000UL);
- SubEvt_setId(partEvt, SubEvt_id(partEvt) | 0x80000000UL);
- syslog(LOG_ERR, "(%s)Trigger tag mismatch: 0x%08x (%d) != 0x%08x",
- my->race[i]->name,trigTag,firstRace,SubEvt_trigNr(subEvt));
+ if ((size = HwRace_readSubEvt(my->race[i], subEvt)) > 0) {
+ if (firstRace < 0) {
+ trigTag = SubEvt_trigNr(subEvt) & 0xff;
+ firstRace = i;
+ } else {
+ if (trigTag != (SubEvt_trigNr(subEvt) & 0xff)) {
+ SubEvt_setId(subEvt, SubEvt_id(subEvt) | 0x80000000UL);
+ SubEvt_setId(partEvt, SubEvt_id(partEvt) | 0x80000000UL);
+ syslog(LOG_ERR, "(%s)Trigger tag mismatch: 0x%08x (%d) != 0x%08x",
+ my->race[i]->name, trigTag, firstRace, SubEvt_trigNr(subEvt));
+ }
}
- }
- subEvt = SubEvt_next(partEvt, subEvt);
+ subEvt = SubEvt_next(partEvt, subEvt);
}
}
SubEvt_setTrigNr(partEvt, trigNr << 8 | trigTag);
- SubEvt_setSize(partEvt, (char *)subEvt - (char *)partEvt);
+ SubEvt_setSize(partEvt, (char *) subEvt - (char *) partEvt);
trigNr++;
assert(SubEvt_size(partEvt) <= my->maxSubEvtSize);
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwship.c,v 6.24 2002-10-15 12:12:29 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwship.c,v 6.25 2002-10-15 16:27:24 hadaq Exp $";
#include <assert.h>
#include <string.h>
cardBase = 0;
}
my->lvme = malloc(sizeof(LVme));
- if (0 > conLVme(my->lvme, cardBase, 0x400000UL, 0x39UL, 0, 0)) {
+ if (0 > conLVme(my->lvme, cardBase, 0x400000UL, 0x39UL, LVL2_OFFSET, 4)) {
syslog(LOG_ERR, "HwShip on %p not found", cardBase);
return -1;
}
if (size > 0x1900) {
syslog(LOG_ERR, "Error, size too large: %.8x", size);
- tempPtr = data - 0x1600;
+ tempPtr = (unsigned long *)(data - 0x1600);
str[0] = 0;
for (i = 0; i < 100; i++) {
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwshow.c,v 6.24 2002-10-15 12:12:29 hadaq Exp $";
-
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwshow.c,v 6.25 2002-10-15 16:27:25 hadaq Exp $";
#define _POSIX_C_SOURCE 199309L
#include <unistd.h>
#include "subevt.h"
#include "hwship.h"
-/* Set number of RCs here */
-#define NSHIPS 12
-
struct HardwareS {
size_t maxSubEvtSize;
- HwShip *ship[NSHIPS];
+ int nShips;
+ HwShip **ship;
};
#include "hardware.h"
return 0;
}
-Hardware *newHardware(void)
+Hardware *newHardware(const char *subsystem)
{
Hardware *my;
Param paramS, *param = ¶mS;
int i;
+ const char *ss;
+ char cardsS[PARAM_MAX_ARRAY_LEN][PARAM_MAX_VALUE_LEN];
+ char *cards[PARAM_MAX_ARRAY_LEN];
+ int nCards;
+
+ for (i = 0; i < PARAM_MAX_ARRAY_LEN; i++) {
+ cards[i] = cardsS[i];
+ }
+
+ if (strcmp(subsystem, "unknown") == 0) {
+ ss = "show";
+ syslog(LOG_NOTICE, "Subsystem not set, defaulting to %s", ss);
+ } else {
+ ss = subsystem;
+ }
if (0 > conParam(param)) {
- syslog(LOG_ERR, "%s:%d:%s", __FILE__, __LINE__, strerror(errno));
+ syslog(LOG_ERR, "Construction of parameter source failed: %s", strerror(errno));
+ return NULL;
+ }
+ if (0 > getCards(param, ss, "ipc", &nCards, cards)) {
+ syslog(LOG_ERR, "Retrieval of card list failed");
return NULL;
}
my = malloc(sizeof(Hardware));
+ my->ship = malloc(nCards * sizeof(HwShip *));
- /*my->maxSubEvtSize = SubEvt_hdrSize() + (NSHIPS * 1600 * sizeof(uint32_t));*/
- my->maxSubEvtSize = SubEvt_hdrSize() + (NSHIPS * 1900 * sizeof(uint32_t));
-
- syslog(LOG_WARNING, "max subevent size: %.8x", my->maxSubEvtSize);
-
-
- for (i = 0; i < NSHIPS; i++) {
- char buf[12];
+#if 0
+ my->maxSubEvtSize = SubEvt_hdrSize() + (nCards * 1600 * sizeof(uint32_t));
+#endif
+ my->maxSubEvtSize = SubEvt_hdrSize() + (nCards * 1900 * sizeof(uint32_t));
+ my->nShips = nCards;
+ for (i = 0; i < my->nShips; i++) {
my->ship[i] = malloc(sizeof(HwShip));
- sprintf(buf, "ipc%d", i);
- if (0 > conHwShip(my->ship[i], buf, param)) {
- syslog(LOG_ERR, "%s:%d:%s", __FILE__, __LINE__, strerror(errno));
+ if (0 > conHwShip(my->ship[i], cards[i], param)) {
+ syslog(LOG_ERR, "Construction of card %s failed:%s", cards[i], strerror(errno));
return NULL;
}
}
-
desParam(param);
return my;
}
{
int i;
- for (i = 0; i < NSHIPS; i++) {
+ for (i = 0; i < my->nShips; i++) {
desHwShip(my->ship[i]);
free(my->ship[i]);
}
+ free(my->ship);
free(my);
}
int i;
int nRequests = 0;
- for (i = 0; i < NSHIPS; i++) {
+ for (i = 0; i < my->nShips; i++) {
if (HwShip_isEmpty(my->ship[i])) {
HwShip_requestBuffer(my->ship[i]);
++nRequests;
}
do {
- for (i = 0; i < NSHIPS; i++) {
+ for (i = 0; i < my->nShips; i++) {
if (HwShip_isBufRequested(my->ship[i])) {
if (!HwShip_isBusy(my->ship[i])) {
HwShip_getEndOfData(my->ship[i]);
* time systems if the priority of readout is not lowered.
* When not using the sleep use option -p -2 for daq_readout.
*/
- if (nRequests == NSHIPS) {
+ if (nRequests == my->nShips) {
struct timespec tS, *t = &tS;
t->tv_sec = 0;
t->tv_nsec = 020000000;
int firstShip = -1;
void *subEvt = SubEvt_data(partEvt);
static uint32_t trigNr = 0;
- uint32_t trigTag = 0;
+ uint32_t trigTag;
/* init partial event, necessary for SubEvt_next() */
SubEvt_setDecoding(partEvt, SubEvtDecoding_SubEvts);
SubEvt_setId(partEvt, 0);
/* read all ships, check for common trigger tag */
- for (i = 0; i < NSHIPS; i++) {
+ for (i = 0; i < my->nShips; i++) {
if (HwShip_readSubEvt(my->ship[i], subEvt) == 0) {
if (firstShip < 0) {
trigTag = SubEvt_trigNr(subEvt) & 0xff;
-T HwV488
-T HwV556
-T HwDtu
+-T HwRace
-T HwShip
-T LVme