From 48f853aa1a217ec0ab7f076e2e618a36c04b4cf0 Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Tue, 20 Jun 2017 12:38:59 +0200 Subject: [PATCH] fixed gui getting stuck (wrong datathreadmask more than 64 bits cuz of 72 sockets) --- .../gotthardDetectorServer/firmware_funcs.c | 21 +-- .../gotthardDetectorServer/firmware_funcs.h | 1 + .../gotthardDetectorServer/server.c | 1 + .../gotthardDetectorServer/server_funcs.c | 1 - .../gotthardDetectorServer/trimming_funcs.c | 20 +-- .../multiSlsDetector/multiSlsDetector.cpp | 147 +++++++++++++++++- 6 files changed, 162 insertions(+), 29 deletions(-) diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c index 615427959..8366f8eb4 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.c @@ -14,6 +14,7 @@ #include + //for memory mapping u_int64_t CSP0BASE; @@ -171,8 +172,8 @@ int mapCSP0(void) { return FAIL; } #endif - printf("CSPObase is 0x%x \n",CSP0BASE); - printf("CSPOBASE=from %08x to %x\n",CSP0BASE,CSP0BASE+MEM_SIZE); + printf("CSPObase is 0x%llx \n",CSP0BASE); + printf("CSPOBASE=from %llx to %llx\n",CSP0BASE,CSP0BASE+MEM_SIZE); u_int32_t address; address = FIFO_DATA_REG_OFF; @@ -827,7 +828,7 @@ u_int32_t testRAM(void) { int i=0; allocateRAM(); // while(i<100000) { - memcpy(ram_values, values, dataBytes); + memcpy((char*)ram_values, (char*)values, dataBytes); printf ("Testing RAM:\t%d: copied fifo %x to memory %x size %d\n",i++, (unsigned int)(values), (unsigned int)(ram_values), dataBytes); // } return result; @@ -970,7 +971,7 @@ int64_t getActualTime(){ int64_t getMeasurementTime(){ int64_t v=get64BitReg(GET_MEASUREMENT_TIME_LSB_REG, GET_MEASUREMENT_TIME_MSB_REG); - int64_t mask=0x8000000000000000; + u_int64_t mask=0x8000000000000000; if (v & mask ) { #ifdef VERBOSE printf("no measurement time left\n"); @@ -1000,7 +1001,7 @@ int loadImage(int index, short int ImageVals[]){ for(i=0;i<6;i++) printf("%d:%d\t",i,ImageVals[i]); #endif - memcpy(ptr,ImageVals ,dataBytes); + memcpy((char*)ptr,(char*)ImageVals ,dataBytes); #ifdef VERBOSE printf("\nLoaded x%08x address with image of index %d\n",(unsigned int)(ptr),index); #endif @@ -1816,7 +1817,7 @@ int allocateRAM() { int prepareADC(){ printf("Preparing ADC\n"); u_int32_t valw,codata,csmask; - int i,j,cdx,ddx,value; + int i,j,cdx,ddx; cdx=0; ddx=1; csmask=0x7c; // 1111100 @@ -2208,7 +2209,7 @@ int readCounterBlock(int startACQ, short int CounterVals[]){ printf("Value of multipurpose reg:%d\n",bus_r(MULTI_PURPOSE_REG)); #endif - memcpy(CounterVals,ptr,dataBytes); + memcpy((char*)CounterVals,(char*)ptr,dataBytes); #ifdef VERBOSE int i; printf("Copied counter memory block with size of %d bytes..\n",dataBytes); @@ -2278,7 +2279,7 @@ int resetCounterBlock(int startACQ){ #endif - memcpy(counterVals,ptr,dataBytes); + memcpy((char*)counterVals,(char*)ptr,dataBytes); #ifdef VERBOSE int i; printf("Copied counter memory block with size of %d bytes..\n",(int)sizeof(counterVals)); @@ -2350,7 +2351,7 @@ int calibratePedestal(int frames){ int a; for (a=0;a<1280; a++){ - unsigned short v = (frame[a] << 8) + (frame[a] >> 8); + //unsigned short v = (frame[a] << 8) + (frame[a] >> 8); // printf("%i: %i %i\n",a, frame[a],v); avg[a] += ((double)frame[a])/(double)frames; //if(frame[a] == 8191) @@ -2377,7 +2378,7 @@ int calibratePedestal(int frames){ - double nf = (double)numberFrames; + //double nf = (double)numberFrames; for(i =0; i < 1280; i++){ adc = i / 256; adcCh = (i - adc * 256) / 32; diff --git a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h index 975342e92..9904bc1f7 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h +++ b/slsDetectorSoftware/gotthardDetectorServer/firmware_funcs.h @@ -72,6 +72,7 @@ int getAdcConfigured(); u_int64_t getDetectorNumber(); u_int32_t getFirmwareVersion(); +u_int32_t getFirmwareSVNVersion(); int testFifos(void); u_int32_t testFpga(void); u_int32_t testRAM(void); diff --git a/slsDetectorSoftware/gotthardDetectorServer/server.c b/slsDetectorSoftware/gotthardDetectorServer/server.c index 2a61aeac6..2c571d748 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/server.c +++ b/slsDetectorSoftware/gotthardDetectorServer/server.c @@ -6,6 +6,7 @@ #include "communication_funcs.h" #include "server_funcs.h" #include +#include extern int sockfd; diff --git a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c index b7ee31dd6..28a9d7e67 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/server_funcs.c @@ -2376,7 +2376,6 @@ int set_speed(int file_des) { int set_readout_flags(int file_des) { enum readOutFlags arg; - int n; int ret=FAIL; diff --git a/slsDetectorSoftware/gotthardDetectorServer/trimming_funcs.c b/slsDetectorSoftware/gotthardDetectorServer/trimming_funcs.c index 9a28b9b4a..6f0d726e8 100755 --- a/slsDetectorSoftware/gotthardDetectorServer/trimming_funcs.c +++ b/slsDetectorSoftware/gotthardDetectorServer/trimming_funcs.c @@ -164,8 +164,8 @@ int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) { double vthreshmean, vthreshSTDev; int *thrmi, *thrma; double c; - double b=BVTRIM; - double a=AVTRIM; + //double b=BVTRIM; + //double a=AVTRIM; int *trim; int ich, imod, ichan; int nvalid=0; @@ -236,7 +236,7 @@ int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) { while (runBusy()) { } usleep(500); - fifodata=fifo_read_event(); + fifodata=(int*)fifo_read_event(); scan=decode_data(fifodata); for (imod=modmi; imod= 96) { + cprintf(BG_RED,"Error: Too many sockets %d for gui to process. Goodbye!", numSockets); + createReceivingDataSockets(true); + exit(EXIT_FAILURE); + } //wait for real time acquisition to start bool running = true; @@ -5290,22 +5299,41 @@ void multiSlsDetector::readFrameFromReceiver(){ if(checkJoinThread()) running = false; - for(int i = 0; i < numSockets; ++i) - dataThreadMask|=(1<numberOfDetectors); //reset frame memory //get each frame for(int isocket=0; isocket= 32) && (isocket < 64) &&((1 << (isocket-32)) & dataThreadMask2)) || //next 32 sockets + ((isocket >= 64) && ((1 << (isocket-64)) & dataThreadMask3))) { //next set of sockets + //if((1 << isocket) & dataThreadMask){ + cout<<"isocket running"<numberOfDetectors); //reset frame memory + + //get each frame + for(int isocket=0; isocket