adding printouts , resetting an image size for each listen image, if last image is not complete, it should be checked with rc==0 and not if itis transmitting, else it doesnt send last incomplete image

This commit is contained in:
Dhanya Maliakal 2017-06-21 17:07:45 +02:00
parent cbd1570a8c
commit 1c7ff1dd8c
4 changed files with 39 additions and 18 deletions

View File

@ -10,6 +10,8 @@
#include "ansi.h"
//#include "sls_receiver_defs.h"
//#define ZMQ_DETAIL
#include <zmq.h>
#include <errno.h>
#include <netdb.h> //gethostbyname()
@ -303,21 +305,23 @@ public:
int len = ReceiveMessage(index, message);
if ( len > 0 ) {
bool dummy = false;
#ifdef VERBOSE
cprintf( BLUE,"Header %d Length: %d Header:%s \n", index, len, (char*) zmq_msg_data (&message) );
#ifdef ZMQ_DETAIL
cprintf( BLUE,"Header %d [%d] Length: %d Header:%s \n", index, portno, len, (char*) zmq_msg_data (&message) );
#endif
if ( ParseHeader (index, len, message, acqIndex, frameIndex, subframeIndex, filename, dummy)) {
zmq_msg_close (&message);
#ifdef VERBOSE
cprintf( RED,"Parsed Header %d Length: %d Header:%s \n", index, len, (char*) zmq_msg_data (&message) );
#ifdef ZMQ_DETAIL
cprintf( RED,"Parsed Header %d [%d] Length: %d Header:%s \n", index, portno, len, (char*) zmq_msg_data (&message) );
#endif
zmq_msg_close (&message);
if (dummy) {
#ifdef VERBOSE
cprintf(RED,"%d Received end of acquisition\n", index);
#ifdef ZMQ_DETAIL
cprintf(RED,"%d [%d] Received end of acquisition\n", index, portno );
#endif
return 0;
}
cprintf(GREEN,"%d data\n",index);
#ifdef ZMQ_DETAIL
cprintf(GREEN,"%d [%d] data\n",index, portno );
#endif
return 1;
}
}

View File

@ -275,6 +275,9 @@ void DataProcessor::ThreadExecution() {
//check dummy
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
#ifdef VERBOSE
if (!index) cprintf(BLUE,"DataProcessor %d, Numbytes:%u\n", index,numBytes);
#endif
if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer);
return;
@ -292,6 +295,10 @@ void DataProcessor::ThreadExecution() {
void DataProcessor::StopProcessing(char* buf) {
#ifdef VERBOSE
if (!index)
cprintf(RED,"DataProcessing %d: Dummy\n", index);
#endif
//stream or free
if (*dataStreamEnable)
fifo->PushAddressToStream(buf);
@ -318,7 +325,8 @@ void DataProcessor::ProcessAnImage(char* buf) {
#ifdef VERBOSE
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum);
if (!index)
cprintf(BLUE,"DataProcessing %d: fnum:%lu\n", index, fnum);
#endif
if (!measurementStartedFlag) {

View File

@ -183,11 +183,14 @@ void DataStreamer::ThreadExecution() {
char* buffer=0;
fifo->PopAddressToStream(buffer);
#ifdef FIFODEBUG
if (!index) cprintf(BLUE,"DataProcessor %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
if (!index) cprintf(BLUE,"DataStreamer %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
#endif
//check dummy
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
#ifdef VERBOSE
cprintf(GREEN,"DataStreamer %d, Numbytes:%u\n", index,numBytes);
#endif
if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer);
return;
@ -203,7 +206,10 @@ void DataStreamer::ThreadExecution() {
void DataStreamer::StopProcessing(char* buf) {
#ifdef VERBOSE
if (!index)
cprintf(RED,"DataStreamer %d: Dummy\n", index);
#endif
sls_detector_header* header = (sls_detector_header*) (buf);
//send dummy header and data
if (!SendHeader(header, true))
@ -222,7 +228,7 @@ void DataStreamer::ProcessAnImage(char* buf) {
sls_detector_header* header = (sls_detector_header*) (buf);
uint64_t fnum = header->frameNumber;
#ifdef VERBOSE
if (!index) cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum);
cprintf(MAGENTA,"DataStreamer %d: fnum:%lu\n", index,fnum);
#endif
if (!measurementStartedFlag) {

View File

@ -251,7 +251,7 @@ void Listener::ThreadExecution() {
//udpsocket doesnt exist
if (*activated && !udpSocket) {
FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
//FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
(*((uint32_t*)buffer)) = 0;
StopListening(buffer);
return;
@ -265,15 +265,16 @@ void Listener::ThreadExecution() {
rc = CreateAnImage(buffer + generalData->fifoBufferHeaderSize);
}
//done acquiring
/*//done acquiring
if ((*status == TRANSMITTING) || ( (!(*activated)) && (rc == 0)) ) {
StopListening(buffer);
return;
}
}*/
//error check, (should not be here) if not transmitting yet (previous if) rc should be > 0
if (rc <= 0) {
cprintf(BG_RED,"Error:(Weird Early self shut down), UDP Sockets not shut down, but received nothing\n");
//cprintf(BG_RED,"Error:(Weird Early self shut down), UDP Sockets not shut down, but received nothing\n");
StopListening(buffer);
return;
}
@ -282,8 +283,10 @@ void Listener::ThreadExecution() {
(*((uint64_t*)(buffer + FIFO_HEADER_NUMBYTES ))) = currentFrameIndex; //for those returning earlier
currentFrameIndex++;
//push into fifo
fifo->PushAddress(buffer);
}
@ -317,11 +320,10 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//reset to -1
memset(buf, 0, fifohsize);
memset(buf + fifohsize, 0xFF, dsize);
memset(buf + fifohsize, 0xFF, generalData->imageSize);
new_header = (sls_detector_header*) (buf + FIFO_HEADER_NUMBYTES);
//look for carry over
if (carryOverFlag) {
cprintf(RED,"%d carry flag\n",index);
@ -422,6 +424,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
//------------------------------------------------------------------------------------------------------------
lastCaughtFrameIndex = fnum;
#ifdef VERBOSE
//if (!index)
cprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n",