#include "shmtrans.h"
#define MAXINPATH 100
+#define DESCLEN 64
+
+
+
+
static char msglog[300];
unsigned long *coreNr;
} TheStats;
+typedef struct dataSourceMapS {
+ unsigned long portNr; /* input port number*/
+ unsigned long subId; /* subevent id*/
+ char description[DESCLEN]; /* description of data sender hub*/
+
+} dataSourceMap;
+
+
+
+static dataSourceMap theDataSenders[MAXINPATH];
+static int maxdatasource=0;
+
+
static jmp_buf terminateJmp;
void sigHandler(int sig)
}
}
+
+
+static void InitDataSenders()
+{
+ int i;
+ FILE* fp;
+ char *line = NULL;
+ size_t len = 0;
+ ssize_t read;
+ int subid;
+ int port;
+ int on;
+ char descriptor [DESCLEN];
+ char dummy [DESCLEN];
+
+ for(i=0; i< MAXINPATH; ++i)
+ {
+ theDataSenders[i].portNr=0;
+ theDataSenders[i].subId=0;
+ snprintf(theDataSenders[i].description, MAXINPATH, "unknown sender");
+ }
+
+
+
+
+ /* TODO: get subid and descriptions from hadesaq/main/data_sources.db
+ we add manually the port lsb here*/
+ fp = fopen("data_sources_ports.db", "r");
+ if(fp==NULL)
+ {
+ printf ("Could not read map of data sources data_sources_ports.db. \n");
+ return;
+ }
+ i=0;
+
+ while ((read = getline(&line, &len, fp)) != -1) {
+
+ /*printf("Retrieved line of length %zu :\n", read);
+ printf("%s", line);*/
+ if (line[0]=='#') continue;
+ sscanf (line, "%x %d %x %s %s", &subid, &on, &port, descriptor, dummy);
+ theDataSenders[i].subId=subid;
+ theDataSenders[i].portNr=port;
+ snprintf(theDataSenders[i].description, DESCLEN, descriptor);
+ printf ("i:%d (0x%x), port:0x%x descriptor=%s \n",i,subid, port, descriptor);
+ ++i;
+ if(i>MAXINPATH) break;
+ }
+ maxdatasource=i;
+ free(line);
+ fclose(fp);
+
+
+}
+
+/* find out subeventid and data sender description JAM*/
+static void getDataSender(unsigned portNum, unsigned int* subid, char* description)
+{
+int i;
+for(i=0; i<maxdatasource; ++i)
+ {
+ /*printf ("getDataSender Checking i:%d , port:0x%x descriptor=%s \n",i,theDataSenders[i].portNr , theDataSenders[i].description);*/
+ if((unsigned long) (portNum & 0xFF) == theDataSenders[i].portNr)
+ {
+ *subid=theDataSenders[i].subId;
+ snprintf(description,DESCLEN,theDataSenders[i].description);
+ /*printf ("FOUND!\n");*/
+ return;
+ }
+ }
+}
+
+
static int checkDataSources(TheArgs *theArgs, TheStats *theStats)
{
int ready2check = 0;
int i;
+ unsigned port=0;
+ unsigned subid=0;
+ char descriptor[DESCLEN];
static unsigned long dataSources[MAXINPATH];
static int once = 1;
if (ready2check) {
for (i = 0; i < theArgs->nrOfMsgs; i++) {
if (dataSources[i] == 0) {
- sprintf(msglog, "<E> daq_netmem: source %d, port %lu: no data received.", i, theArgs->portNr[i]);
+ /* here more precise information which source failed JAM*/
+ getDataSender(theArgs->portNr[i],&subid,descriptor);
+
+ sprintf(msglog, "<E> daq_netmem: source %d, port %lu (0x%x) => subevent 0x%x (%s): no data received.",
+ i, theArgs->portNr[i], theArgs->portNr[i], subid, descriptor);
fprintf(stderr, "%s\n", msglog);
storeLogInfo(theArgs, msglog);
openlog(argv[0], LOG_PID | LOG_PERROR, LOG_LOCAL0);
setlogmask(LOG_UPTO(LOG_INFO));
-
+ InitDataSenders();
argsDefault(theArgs);
argsFromParam(theArgs, argc, argv);
if (0 > argsFromCL(theArgs, argc, argv)) {