From 0549b0ab23f371eea87480cc011687ca74264144 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Adamczewski-Musch?= Date: Tue, 6 May 2014 18:07:55 +0200 Subject: [PATCH] Added debug output for discarded messages in netmem. To debug lost own trigger type situation. --- hadaq/netmem.c | 15 ++++++++++++++- hadaq/nettrans.c | 27 ++++++++++++++++++++++++++- hadaq/nettrans.h | 2 ++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/hadaq/netmem.c b/hadaq/netmem.c index 192b715..b8222f2 100644 --- a/hadaq/netmem.c +++ b/hadaq/netmem.c @@ -460,6 +460,8 @@ static int checkDataSources(TheArgs *theArgs, TheStats *theStats) } } + + if (go2exit) return -1; @@ -865,10 +867,21 @@ int main(int argc, char *argv[]) NetTrans_multiReceive(netTrans, fdSet, theArgs->nrOfMsgs); for (i = 0; i < theArgs->nrOfMsgs; i++) { if (FD_ISSET(netTrans[i]->fd, fdSet)) { - if (assembleMsg(netTrans[i], hadTu[i], hadTuSize[i])) { + if (assembleMsg(netTrans[i], hadTu[i], hadTuSize[i])) { ShmTrans_send(shmTrans[i]); hadTu[i] = NULL; } + else if (netTrans[i]->discardflag!=0) + { + unsigned subid=0; + char descriptor[DESCLEN]; + getDataSender(theArgs->portNr[i],&subid,descriptor); + sprintf(msglog," Input:%d, port:0x%x subevent:0x%x(%s) - %s", i,theArgs->portNr[i],subid,descriptor, netTrans[i]->discardmessage); + storeLogInfo(theArgs, msglog); + netTrans[i]->discardflag=0; + + } + } } diff --git a/hadaq/nettrans.c b/hadaq/nettrans.c index db1b5ab..d7cc964 100644 --- a/hadaq/nettrans.c +++ b/hadaq/nettrans.c @@ -24,6 +24,10 @@ static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hada #include "worker.h" #include "nettrans.h" +static char* transmsglog[300]; + +#define LOGDISCARDEDMESSAGEINTERVAL 100 + static int min(int a, int b) { return a < b ? a : b; @@ -343,10 +347,31 @@ int assembleMsg(NetTrans *my, void *hadTu, size_t size) } else { size_t size; + size = adjustedSize(my, hadTu); if (my->offset != size || memcmp(HadTu_end(hadTu), hadTu, 32)) { - (*my->msgsDiscarded)++; + + (*my->msgsDiscarded)++; + /* JAM: put here debug output for discarded multieventqueue messages:*/ + if(((*my->msgsDiscarded) % LOGDISCARDEDMESSAGEINTERVAL)==0) + { + int cursor=0; + my->discardflag=1; + if(my->offset != size) + { + + cursor=sprintf(my->discardmessage, "assembleMsg: msg %d discarded because packetoffset%d != hadtu size:%d ", (*my->msgsDiscarded), my->offset, size); + } + if( memcmp(HadTu_end(hadTu), hadTu, 32)) + { + sprintf((my->discardmessage+cursor), "assembleMsg: msg %d discarded because mismatch of hadtu header and trailer", (*my->msgsDiscarded)); + } + + } + + + retVal = 0; } else { (*my->msgsReceived)++; diff --git a/hadaq/nettrans.h b/hadaq/nettrans.h index 1471dae..7916040 100644 --- a/hadaq/nettrans.h +++ b/hadaq/nettrans.h @@ -38,6 +38,8 @@ typedef struct NetTransS { unsigned long *msgsReceived; unsigned long *msgsDiscarded; unsigned long *bytesReceived; + int discardflag; + char discardmessage[512]; } NetTrans; int NetTrans_invariant(const NetTrans *my); -- 2.43.0