diff --git a/slsReceiverSoftware/gitInfo.txt b/slsReceiverSoftware/gitInfo.txt index b7d999556..ee5b9127b 100644 --- a/slsReceiverSoftware/gitInfo.txt +++ b/slsReceiverSoftware/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorsPackage/slsReceiverSoftware URL: origin git@git.psi.ch:sls_detectors_software/sls_receiver_software.git Repository Root: origin git@git.psi.ch:sls_detectors_software/sls_receiver_software.git -Repsitory UUID: 1e33a1e0f7de91e255f4a1553445f80d184d84d2 -Revision: 620 +Repsitory UUID: abdbd15341f292983b3943639c54404c700fbdb8 +Revision: 622 Branch: 3.0-rc Last Changed Author: Dhanya_Maliakal -Last Changed Rev: 625 -Last Changed Date: 2017-08-08 08:55:46.000000002 +0200 ./src/utilities.cpp +Last Changed Rev: 627 +Last Changed Date: 2017-08-09 17:19:52.000000002 +0200 ./src/Listener.cpp diff --git a/slsReceiverSoftware/include/Listener.h b/slsReceiverSoftware/include/Listener.h index 8a0e57d2c..b711a8395 100644 --- a/slsReceiverSoftware/include/Listener.h +++ b/slsReceiverSoftware/include/Listener.h @@ -278,5 +278,8 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject { /** if the standard header is implemented in firmware */ bool standardheader; + + /** if the udp socket is connected */ + bool udpSocketAlive; }; diff --git a/slsReceiverSoftware/include/genericSocket.h b/slsReceiverSoftware/include/genericSocket.h index d6726f8b7..40fb2e311 100644 --- a/slsReceiverSoftware/include/genericSocket.h +++ b/slsReceiverSoftware/include/genericSocket.h @@ -637,10 +637,10 @@ enum communicationProtocol{ break; //incomplete packets or header packets ignored and read buffer again if(nsent != packet_size && nsent != header_packet_size) - bprintf(RED,"Incomplete Packet size %d\n",nsent); + bprintf(RED,"%d Incomplete Packet size %d\n", portno, nsent); } //nsent = 1040; - total_sent+=nsent; + if(nsent > 0)total_sent+=nsent; } break; default: diff --git a/slsReceiverSoftware/include/gitInfoReceiver.h b/slsReceiverSoftware/include/gitInfoReceiver.h index ae8a441d3..6980758e1 100644 --- a/slsReceiverSoftware/include/gitInfoReceiver.h +++ b/slsReceiverSoftware/include/gitInfoReceiver.h @@ -1,11 +1,11 @@ //#define SVNPATH "" #define SVNURL "git@git.psi.ch:sls_detectors_software/sls_receiver_software.git" //#define SVNREPPATH "" -#define SVNREPUUID "1e33a1e0f7de91e255f4a1553445f80d184d84d2" -//#define SVNREV 0x625 +#define SVNREPUUID "abdbd15341f292983b3943639c54404c700fbdb8" +//#define SVNREV 0x627 //#define SVNKIND "" //#define SVNSCHED "" #define SVNAUTH "Dhanya_Maliakal" -#define SVNREV 0x625 -#define SVNDATE 0x20170808 +#define SVNREV 0x627 +#define SVNDATE 0x20170809 // diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index c7381260e..5be7b4a6c 100644 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -48,7 +48,8 @@ Listener::Listener(detectorType dtype, Fifo*& f, runStatus* s, uint32_t* portno, currentFrameIndex(0), carryOverFlag(0), carryOverPacket(0), - listeningPacket(0) + listeningPacket(0), + udpSocketAlive(0) { if(ThreadObject::CreateThread()){ pthread_mutex_lock(&Mutex); @@ -223,6 +224,7 @@ int Listener::CreateUDPSockets() { FILE_LOG(logERROR) << "Could not create UDP socket on port " << *udpPortNumber << " error: " << iret; return FAIL; } + udpSocketAlive = true; return OK; } @@ -230,11 +232,11 @@ int Listener::CreateUDPSockets() { void Listener::ShutDownUDPSocket() { if(udpSocket){ + udpSocketAlive = false; udpSocket->ShutDownSocket(); FILE_LOG(logINFO) << "Shut down of UDP port " << *udpPortNumber; fflush(stdout); - delete udpSocket; - udpSocket = 0; + //delete socket at stoplistening } } @@ -250,7 +252,7 @@ void Listener::ThreadExecution() { #endif //udpsocket doesnt exist - if (*activated && !udpSocket && !carryOverFlag) { + if (*activated && !udpSocketAlive && !carryOverFlag) { //FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier"; (*((uint32_t*)buffer)) = 0; StopListening(buffer); @@ -258,7 +260,7 @@ void Listener::ThreadExecution() { } //get data - if ((*status != TRANSMITTING && udpSocket) || carryOverFlag) { + if ((*status != TRANSMITTING && udpSocketAlive) || carryOverFlag) { if (*activated) rc = ListenToAnImage(buffer); else @@ -274,8 +276,11 @@ void Listener::ThreadExecution() { //error check, (should not be here) if not transmitting yet (previous if) rc should be > 0 if (rc <= 0) { - //cprintf(RED,"Error:(Weird Early self shut down), UDP Sockets not shut down, but received nothing\n"); - StopListening(buffer); + //cprintf(RED,"%d Socket shut down while waiting for future packet. udpsocketalive:%d\n",index, udpSocketAlive ); + if (!udpSocketAlive) { + (*((uint32_t*)buffer)) = 0; + StopListening(buffer); + } return; } @@ -295,6 +300,10 @@ void Listener::StopListening(char* buf) { (*((uint32_t*)buf)) = DUMMY_PACKET_VALUE; fifo->PushAddress(buf); StopRunning(); + if (udpSocket) { + delete udpSocket; + udpSocket = 0; + } #ifdef VERBOSE bprintf(GREEN,"%d: Listening Packets (%u) : %llu\n", index, *udpPortNumber, numPacketsCaught); bprintf(GREEN,"%d: Listening Completed\n", index); @@ -304,7 +313,7 @@ void Listener::StopListening(char* buf) { /* buf includes the fifo header and packet header */ uint32_t Listener::ListenToAnImage(char* buf) { - uint32_t rc = 0; + int rc = 0; uint64_t fnum = 0, bid = 0; uint32_t pnum = 0, snum = 0; uint32_t numpackets = 0; @@ -395,7 +404,7 @@ uint32_t Listener::ListenToAnImage(char* buf) { while ( numpackets < pperFrame) { //listen to new packet rc = 0; - if (udpSocket){ + if (udpSocketAlive){ rc = udpSocket->ReceiveDataOnly(listeningPacket); } if(rc <= 0) {