eiger server: vcal=0, rx_fifodepth to greater than 32 bit, trimval argument range check, activate to both control and stop server, end of eiger server (if detectorip normal) set activate to 1 (for future eiger firmware), added setflippeddatax to users, removing warnings and check of detector size before accessing detector[0], updating subexptime also updated subperiod in master file, remove keeprunning in rxr that keeps it busy to semaphore

This commit is contained in:
maliakal_d 2020-03-10 09:25:41 +01:00
parent 9649982932
commit d112956f79
24 changed files with 190 additions and 105 deletions

View File

@ -1,8 +1,8 @@
SLS Detector Package 4.1.1 released on 15.01.2020 (Bug Fix Release) SLS Detector Package 4.2.0 released on 10.03.2020 (Minor Release)
=================================================================== ===================================================================
This document describes the differences between 4.1.0 and 4.1.1 releases. This document describes the differences between 4.2.0 and 4.1.1 releases.
CONTENTS CONTENTS
-------- --------
@ -17,37 +17,38 @@ This document describes the differences between 4.1.0 and 4.1.1 releases.
1. Topics Concerning 1. Topics Concerning
==================== ====================
- detangled receiver streaming from data call back in client - (Eiger) detector server startup with vcal = 0 to reduce noise
and allow for unregister data call back in client - Deactivate will deactivate a module even if FEB does not work.
- (eiger) software trigger made to work along with blocking acquire - trimbits check
- bug fix for locks in blocking acquire - zmqsocket
- parameter file allows for modular commands - fifo size (memory allocation print to mb)
- subexptime also sets subperiod in master fle
- minor check if no detectors ()xxxxxxxxxxxxxxxxxxxxxxx
- setflippeddatax in users xxxxx
- memory alignment in receiver
Compared to 4.1.0,
no firmware or on-board detector server update required for this release.
2. Resolved Issues 2. Resolved Issues
================== ==================
Client Detector Server (Eiger)
------ -----------------------
1. Registering data call back (registerDataCallback) used to enable data streaming 1. Vcal dac set to 0 at on-board detector server start up to
via zmq in both receiver and client. Sending NULL unregistered call back, reduce noise.
but did not disable streaming.
Now, registering/unregistering this call back will only enable data streaming
in client. Data streaming in receiver will have to be explicitly enabled.
2. (Eiger) 2. Deactivate will deactivate a module even if FEB does not work.
Software trigger triggered via the stop server and hence, can be triggered
also during blocking acquire.
3. If stop acquisition command was given immediately after starting a blocking acquire, 3. Trimbits values checked for values 0 - 63.
it might have hanged the process. This bug is fixed now.
4. Parameter file now allows modular commands (using ':'). They are not ignored anymore. Receiver
--------
1. zmq socket send memory not overlapping
2. fifo size not be large (and memory allocated print to mb)
- subexptime also sets subperiod in master fle
3. Known Issues 3. Known Issues
=============== ===============

View File

@ -31,6 +31,7 @@ It is linked in manual/manual-api from slsReceiverSoftware/include ]
#include <unistd.h> //usleep #include <unistd.h> //usleep
#include <errno.h> #include <errno.h>
#include <syscall.h> //tid #include <syscall.h> //tid
#include <semaphore.h>
using namespace std; using namespace std;
@ -38,15 +39,15 @@ using namespace std;
#define PRINT_IN_COLOR(c,f, ...) printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__) #define PRINT_IN_COLOR(c,f, ...) printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__)
/** Variable is true to continue running, set to false upon interrupt */ /** Semaphore that waits, interrupted upon end */
bool keeprunning; sem_t semaphore;
/** /**
* Control+C Interrupt Handler * Control+C Interrupt Handler
* Sets the variable keeprunning to false, to let all the processes know to exit properly * pushes semaphore to stop waiting, to let all the processes know to exit properly
*/ */
void sigInterruptHandler(int p){ void sigInterruptHandler(int p){
keeprunning = false; sem_post(&semaphore);
} }
/** /**
@ -170,7 +171,7 @@ int main(int argc, char *argv[]) {
int numReceivers = 1; int numReceivers = 1;
int startTCPPort = 1954; int startTCPPort = 1954;
int withCallback = 0; int withCallback = 0;
keeprunning = true; sem_init(&semaphore,1,0);
/** - get number of receivers and start tcp port from command line arguments */ /** - get number of receivers and start tcp port from command line arguments */
if ( (argc != 4) || (!sscanf(argv[1],"%d", &startTCPPort)) || (!sscanf(argv[2],"%d", &numReceivers)) || (!sscanf(argv[3],"%d", &withCallback)) ) if ( (argc != 4) || (!sscanf(argv[1],"%d", &startTCPPort)) || (!sscanf(argv[2],"%d", &numReceivers)) || (!sscanf(argv[3],"%d", &withCallback)) )
@ -257,9 +258,9 @@ int main(int argc, char *argv[]) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/** - as long as keeprunning is true (changes with Ctrl+C) */ /** - as long as semaphore waits (changes with Ctrl+C) */
while(keeprunning) sem_wait(&semaphore);
pause(); sem_destroy(&semaphore);
/** - interrupt caught, delete slsReceiverUsers object and exit */ /** - interrupt caught, delete slsReceiverUsers object and exit */
delete receiver; delete receiver;
cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long)syscall(SYS_gettid));

View File

@ -85,15 +85,21 @@ public:
static double getNSTime(timeUnit unit, double value){ static double getNSTime(timeUnit unit, double value){
double valueNS=value; double valueNS=value;
switch(unit){ switch(unit){
case HOURS: valueNS*=60; case HOURS:
case MINUTES: valueNS*=60; return valueNS * 60 * 60 * 1000 * 1000 * 1000;
case SECONDS: valueNS*=1000; case MINUTES:
case MILLISECONDS: valueNS*=1000; return valueNS * 60 * 1000 * 1000 * 1000;
case MICROSECONDS: valueNS*=1000; case SECONDS:
return valueNS * 1000 * 1000 * 1000;
case MILLISECONDS:
return valueNS * 1000 * 1000;
case MICROSECONDS:
return valueNS * 1000;
case NANOSECONDS: case NANOSECONDS:
default:; return valueNS;
default:
return 0;
} }
return valueNS;
}; };
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: e4645a8273c8265bc584579d5f7f8eb6dc4379f7 Repsitory UUID: 9649982932b2db75b9bf720ce4a13e7cdb059430
Revision: 360 Revision: 361
Branch: 4.1.0-rc Branch: 4.1.2-rc
Last Changed Author: GitHub_GitHub Last Changed Author: Gemma_Tinti
Last Changed Rev: 4138 Last Changed Rev: 4157
Last Changed Date: 2019-10-04 09:28:27.000000001 +0200 ./xparameters.h Last Changed Date: 2020-03-09 18:18:12.000000001 +0100 ./xparameters.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "e4645a8273c8265bc584579d5f7f8eb6dc4379f7" #define GITREPUUID "9649982932b2db75b9bf720ce4a13e7cdb059430"
#define GITAUTH "GitHub_GitHub" #define GITAUTH "Gemma_Tinti"
#define GITREV 0x4138 #define GITREV 0x4157
#define GITDATE 0x20191004 #define GITDATE 0x20200309
#define GITBRANCH "4.1.0-rc" #define GITBRANCH "4.1.2-rc"

View File

@ -284,6 +284,9 @@ u_int32_t getDetectorIP(){
FILE* sysFile = popen("ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2", "r"); FILE* sysFile = popen("ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2", "r");
fgets(output, sizeof(output), sysFile); fgets(output, sizeof(output), sysFile);
pclose(sysFile); pclose(sysFile);
if (strlen(output) <= 1) {
return 0;
}
//converting IPaddress to hex. //converting IPaddress to hex.
char* pcword = strtok (output,"."); char* pcword = strtok (output,".");
@ -329,6 +332,15 @@ void initControlServer(){
setupDetector(); setupDetector();
// activate (if it gets ip) (later FW will deactivate at startup)
if (getDetectorIP() != 0) {
Beb_Activate(1);
Feb_Control_activate(1);
} else {
Beb_Activate(0);
Feb_Control_activate(0);
}
#endif #endif
printf("\n"); printf("\n");
} }
@ -344,6 +356,16 @@ void initStopServer(){
Feb_Control_FebControl(); Feb_Control_FebControl();
Feb_Control_Init(master,top,normal,getDetectorNumber()); Feb_Control_Init(master,top,normal,getDetectorNumber());
printf("FEB Initialization done\n"); printf("FEB Initialization done\n");
// activate (if it gets ip) (later FW will deactivate at startup)
// also needed for stop server for status
if (getDetectorIP() != 0) {
Beb_Activate(1);
Feb_Control_activate(1);
} else {
Beb_Activate(0);
Feb_Control_activate(0);
}
#endif #endif
printf("\n"); printf("\n");
} }

View File

@ -31,7 +31,7 @@ enum DACINDEX {SVP,VTR,VRF,VRS,SVN,VTGSTV,VCMP_LL,VCMP_LR,CAL,VCMP_RL,RX
2556, /* Vtgstv */ \ 2556, /* Vtgstv */ \
1000, /* Vcmp_ll */ \ 1000, /* Vcmp_ll */ \
1000, /* Vcmp_lr */ \ 1000, /* Vcmp_lr */ \
4000, /* cal */ \ 0, /* cal */ \
1000, /* Vcmp_rl */ \ 1000, /* Vcmp_rl */ \
1100, /* rxb_rb */ \ 1100, /* rxb_rb */ \
1100, /* rxb_lb */ \ 1100, /* rxb_lb */ \
@ -90,6 +90,7 @@ enum NETWORKINDEX {TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
#define DEFAULT_TEST_MODE (0) #define DEFAULT_TEST_MODE (0)
#define DEFAULT_HIGH_VOLTAGE (0) #define DEFAULT_HIGH_VOLTAGE (0)
#define MAX_TRIMBITS_VALUE (63)
#define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS (0x1FFFFFFF) /** 29 bit register for max subframe exposure value */ #define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS (0x1FFFFFFF) /** 29 bit register for max subframe exposure value */

View File

@ -2670,7 +2670,7 @@ int* multiSlsDetector::getDataFromDetector() {
int nodatadet = -1; int nodatadet = -1;
int nodatadetectortype = false; int nodatadetectortype = false;
detectorType types = getDetectorsType(); detectorType types = getDetectorsType();
if (types == EIGER || types == JUNGFRAU || GOTTHARD || PROPIX) { if (types == EIGER || types == JUNGFRAU || types == GOTTHARD || types == PROPIX) {
nodatadetectortype = true; nodatadetectortype = true;
} }
@ -3108,17 +3108,18 @@ slsDetectorDefs::externalCommunicationMode multiSlsDetector::setExternalCommunic
externalCommunicationMode pol) { externalCommunicationMode pol) {
externalCommunicationMode ret, ret1; externalCommunicationMode ret, ret1;
//(Dhanya) FIXME: why first detector or is it the master one? //(Dhanya) FIXME: why first detector or is it the master one?
if (detectors.size()) if (detectors.size()) {
ret = detectors[0]->setExternalCommunicationMode(pol); ret = detectors[0]->setExternalCommunicationMode(pol);
if (detectors[0]->getErrorMask()) if (detectors[0]->getErrorMask())
setErrorMask(getErrorMask() | (1 << 0)); setErrorMask(getErrorMask() | (1 << 0));
for (unsigned int idet = 1; idet < detectors.size(); ++idet) { for (unsigned int idet = 1; idet < detectors.size(); ++idet) {
ret1 = detectors[idet]->setExternalCommunicationMode(pol); ret1 = detectors[idet]->setExternalCommunicationMode(pol);
if (detectors[idet]->getErrorMask()) if (detectors[idet]->getErrorMask())
setErrorMask(getErrorMask() | (1 << idet)); setErrorMask(getErrorMask() | (1 << idet));
if (ret != ret1) if (ret != ret1)
ret = GET_EXTERNAL_COMMUNICATION_MODE; ret = GET_EXTERNAL_COMMUNICATION_MODE;
}
} }
setMaster(); setMaster();
setSynchronization(); setSynchronization();
@ -3129,17 +3130,18 @@ slsDetectorDefs::externalSignalFlag multiSlsDetector::setExternalSignalFlags(
externalSignalFlag pol, int signalindex) { externalSignalFlag pol, int signalindex) {
externalSignalFlag ret, ret1; externalSignalFlag ret, ret1;
//(Dhanya) FIXME: why first detector or is it the master one? //(Dhanya) FIXME: why first detector or is it the master one?
if (detectors.size()) if (detectors.size()) {
ret = detectors[0]->setExternalSignalFlags(pol, signalindex); ret = detectors[0]->setExternalSignalFlags(pol, signalindex);
if (detectors[0]->getErrorMask()) if (detectors[0]->getErrorMask())
setErrorMask(getErrorMask() | (1 << 0)); setErrorMask(getErrorMask() | (1 << 0));
for (unsigned int idet = 1; idet < detectors.size(); ++idet) { for (unsigned int idet = 1; idet < detectors.size(); ++idet) {
ret1 = detectors[idet]->setExternalSignalFlags(pol, signalindex); ret1 = detectors[idet]->setExternalSignalFlags(pol, signalindex);
if (detectors[idet]->getErrorMask()) if (detectors[idet]->getErrorMask())
setErrorMask(getErrorMask() | (1 << idet)); setErrorMask(getErrorMask() | (1 << idet));
if (ret != ret1) if (ret != ret1)
ret = GET_EXTERNAL_SIGNAL_FLAG; ret = GET_EXTERNAL_SIGNAL_FLAG;
}
} }
setMaster(); setMaster();
setSynchronization(); setSynchronization();
@ -5592,8 +5594,10 @@ int multiSlsDetector::enableDataStreamingToClient(int enable) {
std::cout << "Could not create data threads in client." << std::endl; std::cout << "Could not create data threads in client." << std::endl;
//only for the first det as theres no general one //only for the first det as theres no general one
setErrorMask(getErrorMask() | (1 << 0)); setErrorMask(getErrorMask() | (1 << 0));
detectors[0]->setErrorMask((detectors[0]->getErrorMask()) | if (detectors.size()) {
detectors[0]->setErrorMask((detectors[0]->getErrorMask()) |
(DATA_STREAMING)); (DATA_STREAMING));
}
} }
} }
} }

View File

@ -3689,7 +3689,7 @@ int* slsDetector::getDataFromDetector(int *retval) {
int nodatadetectortype = false; int nodatadetectortype = false;
detectorType types = getDetectorsType(); detectorType types = getDetectorsType();
if(types == EIGER || types == JUNGFRAU || GOTTHARD || PROPIX){ if(types == EIGER || types == JUNGFRAU || types == GOTTHARD || types == PROPIX){
nodatadetectortype = true; nodatadetectortype = true;
} }
@ -3906,7 +3906,9 @@ int slsDetector::configureMAC() {
bzero(cword, 50); bzero(cword, 50);
string s; string s;
while (getline(ss, s, '.')) { while (getline(ss, s, '.')) {
sprintf(cword,"%s%02x",cword,atoi(s.c_str())); char cnum[50]="";
sprintf(cnum, "%02x", atoi(s.c_str()));
strcat(cword, cnum);
} }
bzero(arg[0], 50); bzero(arg[0], 50);
strcpy(arg[0],cword); strcpy(arg[0],cword);
@ -3922,7 +3924,7 @@ int slsDetector::configureMAC() {
bzero(cword, 50); bzero(cword, 50);
string s; string s;
while (getline(ss, s, ':')) { while (getline(ss, s, ':')) {
sprintf(cword,"%s%s",cword,s.c_str()); strcat(cword, s.c_str());
} }
bzero(arg[1], 50); bzero(arg[1], 50);
strcpy(arg[1],cword); strcpy(arg[1],cword);
@ -3941,7 +3943,7 @@ int slsDetector::configureMAC() {
bzero(cword, 50); bzero(cword, 50);
string s; string s;
while (getline(ss, s, ':')) { while (getline(ss, s, ':')) {
sprintf(cword,"%s%s",cword,s.c_str()); strcat(cword, s.c_str());
} }
bzero(arg[3], 50); bzero(arg[3], 50);
strcpy(arg[3],cword); strcpy(arg[3],cword);
@ -3957,7 +3959,9 @@ int slsDetector::configureMAC() {
bzero(cword, 50); bzero(cword, 50);
string s; string s;
while (getline(ss, s, '.')) { while (getline(ss, s, '.')) {
sprintf(cword,"%s%02x",cword,atoi(s.c_str())); char cnum[50]="";
sprintf(cnum, "%02x", atoi(s.c_str()));
strcat(cword, cnum);
} }
bzero(arg[4], 50); bzero(arg[4], 50);
strcpy(arg[4],cword); strcpy(arg[4],cword);
@ -6122,6 +6126,19 @@ int slsDetector::activate(int const enable) {
if (ret==FORCE_UPDATE) if (ret==FORCE_UPDATE)
updateDetector(); updateDetector();
} }
if (connectStop() == OK){
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
stopSocket->SendDataOnly(&arg,sizeof(arg));
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL) {
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector (Stop server) returned error: " << mess << std::endl;
setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE));
} else {
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
}
disconnectStop();
}
} }
#ifdef VERBOSE #ifdef VERBOSE
if(retval==1) if(retval==1)

View File

@ -471,6 +471,14 @@ int slsDetectorActions::executeAction(int level) {
case headerBefore: case headerBefore:
fName=getCurrentFileName(); fName=getCurrentFileName();
nowIndex=getFileIndexFromFileName(getCurrentFileName()); nowIndex=getFileIndexFromFileName(getCurrentFileName());
// all other parameters should be taken using text client calls in the header scripts!
sprintf(cmd,"%s nrun=%d fn=%s par=%s", \
getActionScript(level).c_str(), \
nowIndex, \
fName.c_str(), \
getActionParameter(level).c_str());
break;
case headerAfter: case headerAfter:
// all other parameters should be taken using text client calls in the header scripts! // all other parameters should be taken using text client calls in the header scripts!

View File

@ -3066,7 +3066,9 @@ string slsDetectorCommand::cmdTrimEn(int narg, char *args[], int action){
npos = myDet->getTrimEn(opos); npos = myDet->getTrimEn(opos);
if (npos != -1) { if (npos != -1) {
for (int ip=0; ip<npos;++ip) { for (int ip=0; ip<npos;++ip) {
sprintf(answer,"%s %d",answer,opos[ip]); char cnum[50]="";
sprintf(cnum, " %d", opos[ip]);
strcat(answer, cnum);
} }
} }
} }
@ -3708,7 +3710,9 @@ string slsDetectorCommand::cmdPositions(int narg, char *args[], int action){
double opos[npos]; double opos[npos];
myDet->getPositions(opos); myDet->getPositions(opos);
for (int ip=0; ip<npos;++ip) { for (int ip=0; ip<npos;++ip) {
sprintf(answer,"%s %f",answer,opos[ip]); char cnum[50]="";
sprintf(cnum, " %f", opos[ip]);
strcat(answer, cnum);
} }
return string(answer); return string(answer);
@ -3887,9 +3891,11 @@ string slsDetectorCommand::cmdScans(int narg, char *args[], int action) {
ns=myDet->getScanSteps(is, values); ns=myDet->getScanSteps(is, values);
int p=myDet->getScanPrecision(is); int p=myDet->getScanPrecision(is);
char format[1000]; char format[1000];
sprintf(format, "%%s %%0.%df",p); sprintf(format, " %%0.%df",p);
for (int i=0; i<ns; ++i) { for (int i=0; i<ns; ++i) {
sprintf(answer,format,answer,values[i]); char cnum[50]="";
sprintf(cnum, format, values[i]);
strcat(answer, cnum);
} }
delete [] values; delete [] values;
} }
@ -3954,10 +3960,11 @@ string slsDetectorCommand::cmdScans(int narg, char *args[], int action) {
ns=myDet->getScanSteps(is, values); ns=myDet->getScanSteps(is, values);
int p=myDet->getScanPrecision(is); int p=myDet->getScanPrecision(is);
char format[1000]; char format[1000];
sprintf(format, "%%s %%0.%df",p); sprintf(format, " %%0.%df",p);
sprintf(answer,"%d ",ns);
for (int i=0; i<ns; ++i) { for (int i=0; i<ns; ++i) {
sprintf(answer,format,answer,values[i]); char cnum[50]="";
sprintf(cnum, format, values[i]);
strcat(answer, cnum);
} }
delete [] values; delete [] values;
return string(answer); return string(answer);
@ -5850,7 +5857,7 @@ string slsDetectorCommand::cmdTimeLeft(int narg, char *args[], int action) {
if ((ret!=-1) && (index==ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER if ((ret!=-1) && (index==ACQUISITION_TIME || index==FRAME_PERIOD || index==DELAY_AFTER_TRIGGER
|| index==ACTUAL_TIME || index==MEASUREMENT_TIME || || index==ACTUAL_TIME || index==MEASUREMENT_TIME ||
MEASURED_PERIOD || MEASURED_SUBPERIOD)) { index==MEASURED_PERIOD || index==MEASURED_SUBPERIOD)) {
rval=(double)ret*1E-9; rval=(double)ret*1E-9;
sprintf(answer,"%0.9f",rval); sprintf(answer,"%0.9f",rval);
} else { } else {

View File

@ -314,6 +314,10 @@ int slsDetectorUsers::enableGapPixels(int enable) {
return myDetector->enableGapPixels(enable); return myDetector->enableGapPixels(enable);
} }
int slsDetectorUsers::setFlippedDataX(int value) {
return myDetector->setFlippedData(slsDetectorDefs::X, value);
}
std::string slsDetectorUsers::setReceiverFramesDiscardPolicy(std::string f) { std::string slsDetectorUsers::setReceiverFramesDiscardPolicy(std::string f) {
return myDetector->getReceiverFrameDiscardPolicy( return myDetector->getReceiverFrameDiscardPolicy(
myDetector->setReceiverFramesDiscardPolicy( myDetector->setReceiverFramesDiscardPolicy(

View File

@ -553,6 +553,12 @@ class slsDetectorUsers
*/ */
int enableGapPixels(int enable=-1); int enableGapPixels(int enable=-1);
/** sets the enable which determines if data will be flipped across x axis
* @param value 0 or 1 to reset/set or -1 to get value
* @return enable flipped data across x axis
*/
int setFlippedDataX(int value=-1);
/** /**
* Sets the frames discard policy in receiver * Sets the frames discard policy in receiver
* frame discard policy options: * frame discard policy options:

View File

@ -4361,11 +4361,11 @@ int set_all_trimbits(int file_des){
#ifdef VERBOSE #ifdef VERBOSE
printf("setting all trimbits to %d\n",arg); printf("setting all trimbits to %d\n",arg);
#endif #endif
if(arg < -1){ if(arg < -1 || arg > MAX_TRIMBITS_VALUE){
ret = FAIL; ret = FAIL;
strcpy(mess,"Cant set trimbits to this value\n"); sprintf(mess,"Cant set all trimbits to %d. Range 0 - %d\n", arg, MAX_TRIMBITS_VALUE);
cprintf(RED, "Warning: %s", mess); cprintf(RED, "Warning: %s", mess);
}else { } else {
if(arg >= 0){ if(arg >= 0){
ret = setAllTrimbits(arg); ret = setAllTrimbits(arg);
//changes settings to undefined //changes settings to undefined

View File

@ -312,7 +312,7 @@ public:
"\"quad\":%u" "\"quad\":%u"
;//"}\n"; ;//"}\n";
int length = sprintf(buf, jsonHeaderFormat, sprintf(buf, jsonHeaderFormat,
jsonversion, dynamicrange, fileIndex, ndetx, ndety, npixelsx, npixelsy, imageSize, jsonversion, dynamicrange, fileIndex, ndetx, ndety, npixelsx, npixelsy, imageSize,
acqIndex, fIndex, (fname == NULL)? "":fname, dummy?0:1, acqIndex, fIndex, (fname == NULL)? "":fname, dummy?0:1,
@ -326,10 +326,11 @@ public:
quadEnable quadEnable
); );
if (additionalJsonHeader && strlen(additionalJsonHeader)) { if (additionalJsonHeader && strlen(additionalJsonHeader)) {
length = sprintf(buf, "%s, %s}\n", buf, additionalJsonHeader); strcat(buf, ", ");
} else { strcat(buf, additionalJsonHeader);
length = sprintf(buf, "%s}\n", buf);
} }
strcat(buf,"}\n");
int length = strlen(buf);
#ifdef VERBOSE #ifdef VERBOSE
if(!index) if(!index)

View File

@ -21,7 +21,7 @@
#define FILE_BUFFER_SIZE (16*1024*1024) //16mb #define FILE_BUFFER_SIZE (16*1024*1024) //16mb
//fifo //fifo
#define FIFO_HEADER_NUMBYTES 4 #define FIFO_HEADER_NUMBYTES 8
//hdf5 //hdf5

View File

@ -46,14 +46,14 @@ int Fifo::CreateFifos(uint32_t fifoItemSize) {
fifoFree = new CircularFifo<char>(fifoDepth); fifoFree = new CircularFifo<char>(fifoDepth);
fifoStream = new CircularFifo<char>(fifoDepth); fifoStream = new CircularFifo<char>(fifoDepth);
//allocate memory //allocate memory
size_t mem_len = fifoItemSize * fifoDepth * sizeof(char); size_t mem_len = (size_t)fifoItemSize * (size_t)fifoDepth * sizeof(char);
memory = (char*) malloc (mem_len); memory = (char*) malloc (mem_len);
if (memory == NULL){ if (memory == NULL){
FILE_LOG(logERROR) << "Could not allocate memory for fifos"; FILE_LOG(logERROR) << "Could not allocate memory for fifos";
return FAIL; return FAIL;
} }
memset(memory, 0, mem_len); memset(memory, 0, mem_len);
FILE_LOG(logDEBUG) << "Memory Allocated " << index << ": " << mem_len << " bytes"; FILE_LOG(logDEBUG) << "Memory Allocated " << index << ": " << (double)mem_len/(double)(1024 * 1024) << " MB";
{ //push free addresses into fifoFree fifo { //push free addresses into fifoFree fifo
char* buffer = memory; char* buffer = memory;

View File

@ -397,7 +397,9 @@ void UDPBaseImplementation::setMultiDetectorSize(const int* size) {
numDet[i] = size[i]*2; numDet[i] = size[i]*2;
else else
numDet[i] = size[i]; numDet[i] = size[i];
sprintf(message,"%s%d",message,numDet[i]); char cnum[20]="";
sprintf(cnum, "%d", numDet[i]);
strcat(message, cnum);
if (i < MAX_DIMENSIONS-1 ) if (i < MAX_DIMENSIONS-1 )
strcat(message,","); strcat(message,",");
} }
@ -650,7 +652,7 @@ void UDPBaseImplementation::setSubPeriod(const uint64_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
subPeriod = i; subPeriod = i;
FILE_LOG(logINFO) << "Sub Exposure Time: " << (double)subPeriod/(1E9) << "s"; FILE_LOG(logINFO) << "Sub Period: " << (double)subPeriod/(1E9) << "s";
} }
int UDPBaseImplementation::setNumberOfFrames(const uint64_t i){ int UDPBaseImplementation::setNumberOfFrames(const uint64_t i){

View File

@ -119,7 +119,9 @@ void UDPStandardImplementation::setMultiDetectorSize(const int* size) {
numDet[i] = size[i]*2; numDet[i] = size[i]*2;
else else
numDet[i] = size[i]; numDet[i] = size[i];
sprintf(message,"%s%d",message,numDet[i]); char cnum[20]="";
sprintf(cnum, "%d", numDet[i]);
strcat(message, cnum);
if (i < MAX_DIMENSIONS-1 ) if (i < MAX_DIMENSIONS-1 )
strcat(message,","); strcat(message,",");
} }
@ -834,7 +836,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
if(dataStreamer.size())dataStreamer[i]->SetFifo(fifo[i]); if(dataStreamer.size())dataStreamer[i]->SetFifo(fifo[i]);
} }
FILE_LOG(logINFO) << "Memory Allocated Per Fifo: " << ( ((generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize)) * fifoDepth) << " bytes" ; FILE_LOG(logINFO) << "Memory Allocated Per Fifo: " << (double)( ((generalData->imageSize) * numberofJobs + (generalData->fifoBufferHeaderSize)) * fifoDepth)/ (double)(1024 * 1024) << " MB" ;
FILE_LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed"; FILE_LOG(logINFO) << numThreads << " Fifo structure(s) reconstructed";
return OK; return OK;
} }

View File

@ -16,12 +16,12 @@
#include <sys/wait.h> //wait #include <sys/wait.h> //wait
#include <unistd.h> //usleep #include <unistd.h> //usleep
#include <syscall.h> #include <syscall.h>
#include <semaphore.h>
sem_t semaphore;
bool keeprunning;
void sigInterruptHandler(int p){ void sigInterruptHandler(int p){
keeprunning = false; sem_post(&semaphore);
} }
/* /*
@ -65,7 +65,7 @@ void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
keeprunning = true; sem_init(&semaphore,1,0);
cprintf(BLUE,"Created [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); cprintf(BLUE,"Created [ Tid: %ld ]\n", (long)syscall(SYS_gettid));
// Catch signal SIGINT to close files and call destructors properly // Catch signal SIGINT to close files and call destructors properly
@ -148,8 +148,8 @@ int main(int argc, char *argv[]) {
FILE_LOG(logINFO) << "Ready ... "; FILE_LOG(logINFO) << "Ready ... ";
cprintf(RESET, "\n[ Press \'Ctrl+c\' to exit ]\n"); cprintf(RESET, "\n[ Press \'Ctrl+c\' to exit ]\n");
while(keeprunning) sem_wait(&semaphore);
pause(); sem_destroy(&semaphore);
delete receiver; delete receiver;
cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid)); cprintf(BLUE,"Exiting [ Tid: %ld ]\n", (long)syscall(SYS_gettid));

View File

@ -542,7 +542,7 @@ int slsReceiverTCPIPInterface::set_port() {
try { try {
mySocket = new MySocketTCP(p_number); mySocket = new MySocketTCP(p_number);
strcpy(mySock->lastClientIP,oldLastClientIP); strcpy(mySock->lastClientIP,oldLastClientIP);
} catch(SamePortSocketException e) { } catch(SamePortSocketException& e) {
ret = FAIL; ret = FAIL;
sprintf(mess, "Could not bind port %d. It is already set\n", p_number); sprintf(mess, "Could not bind port %d. It is already set\n", p_number);
FILE_LOG(logERROR) << mess; FILE_LOG(logERROR) << mess;
@ -1039,6 +1039,7 @@ int slsReceiverTCPIPInterface::set_timer() {
// else if (receiverBase->getStatus() != IDLE) // else if (receiverBase->getStatus() != IDLE)
// receiverNotIdle(); // receiverNotIdle();
else { else {
uint64_t subdeadtime = 0;
switch (index[0]) { switch (index[0]) {
case ACQUISITION_TIME: case ACQUISITION_TIME:
ret = receiverBase->setAcquisitionTime(index[1]); ret = receiverBase->setAcquisitionTime(index[1]);
@ -1052,7 +1053,9 @@ int slsReceiverTCPIPInterface::set_timer() {
receiverBase->setNumberOfFrames(index[1]); receiverBase->setNumberOfFrames(index[1]);
break; break;
case SUBFRAME_ACQUISITION_TIME: case SUBFRAME_ACQUISITION_TIME:
subdeadtime = receiverBase->getSubPeriod() - receiverBase->getSubExpTime();
receiverBase->setSubExpTime(index[1]); receiverBase->setSubExpTime(index[1]);
receiverBase->setSubPeriod(receiverBase->getSubExpTime() + subdeadtime);
break; break;
case SUBFRAME_DEADTIME: case SUBFRAME_DEADTIME:
receiverBase->setSubPeriod(index[1] + receiverBase->getSubExpTime()); receiverBase->setSubPeriod(index[1] + receiverBase->getSubExpTime());