diff --git a/slsDetectorSoftware/mythenDetectorServer/Makefile b/slsDetectorSoftware/mythenDetectorServer/Makefile index d0aca04a8..41c0ff11f 100755 --- a/slsDetectorSoftware/mythenDetectorServer/Makefile +++ b/slsDetectorSoftware/mythenDetectorServer/Makefile @@ -13,8 +13,7 @@ INSTMODE= 0777 SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c OBJS= $(SRCS:%.c=%.o) -CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS -#-DVERBOSE +CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS -DVERBOSE #-DVERYVERBOSE #-Werror diff --git a/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c b/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c index c9517e829..a1badb391 100755 --- a/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.c @@ -580,10 +580,14 @@ int64_t set64BitReg(int64_t value, int aLSB, int aMSB){ int64_t get64BitReg(int aLSB, int aMSB){ int64_t v64; u_int32_t vLSB,vMSB; - vLSB=bus_r(aLSB); vMSB=bus_r(aMSB); + vLSB=bus_r(aLSB); v64=vMSB; v64=(v64<<32) | vLSB; +#ifdef VERBOSE + printf("MSB %08x LSB %08x, %016llx\n", vMSB, vLSB, v64); +#endif + return v64; } @@ -699,6 +703,23 @@ int64_t getProgress() { } +int64_t getActualTime(){ + return get64BitReg(GET_ACTUAL_TIME_LSB_REG, GET_ACTUAL_TIME_MSB_REG)/(1E-9*CLK_FREQ); +} + +int64_t getMeasurementTime(){ + int64_t v=get64BitReg(GET_MEASUREMENT_TIME_LSB_REG, GET_MEASUREMENT_TIME_MSB_REG); + int64_t mask=0x8000000000000000; + if (v & mask ) { +#ifdef VERBOSE + printf("no measurement time left\n"); +#endif + return -1E+9; + } else + return v/(1E-9*CLK_FREQ); +} + + int64_t getProbes(){ u_int32_t shiftin=bus_r(GET_SHIFT_IN_REG); diff --git a/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.h b/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.h index 3feb9a637..dfe198015 100755 --- a/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.h +++ b/slsDetectorSoftware/mythenDetectorServer/firmware_funcs.h @@ -78,7 +78,8 @@ int64_t getProbes(); int64_t getProgress(); int64_t setProgress(); - +int64_t getActualTime(); +int64_t getMeasurementTime(); u_int32_t runBusy(void); u_int32_t runState(void); diff --git a/slsDetectorSoftware/mythenDetectorServer/registers.h b/slsDetectorSoftware/mythenDetectorServer/registers.h index 2552a1ada..63c6d7e29 100755 --- a/slsDetectorSoftware/mythenDetectorServer/registers.h +++ b/slsDetectorSoftware/mythenDetectorServer/registers.h @@ -52,10 +52,17 @@ #define SET_TRAINS_LSB_REG 0x01E000 #define SET_TRAINS_MSB_REG 0x01F000 #define GET_TRAINS_LSB_REG 0x020000 -#define GET_TRAINS_MSB_REG 0x021000 +#define GET_TRAINS_MSB_REG 0x021000 + #define GET_SHIFT_IN_REG 0x022000 +#define GET_MEASUREMENT_TIME_LSB_REG 0x023000 +#define GET_MEASUREMENT_TIME_MSB_REG 0x024000 + +#define GET_ACTUAL_TIME_LSB_REG 0x025000 +#define GET_ACTUAL_TIME_MSB_REG 0x026000 + #define MOD_DACS1_REG 0x030000 #define MOD_DACS2_REG 0x040000 diff --git a/slsDetectorSoftware/mythenDetectorServer/server_funcs.c b/slsDetectorSoftware/mythenDetectorServer/server_funcs.c index a89be5ffc..daf9b29ae 100755 --- a/slsDetectorSoftware/mythenDetectorServer/server_funcs.c +++ b/slsDetectorSoftware/mythenDetectorServer/server_funcs.c @@ -74,7 +74,7 @@ int decode_function() { #endif n = receiveDataOnly(&fnum,sizeof(fnum)); if (n <= 0) { - printf("ERROR reading from socket %d", n); + printf("ERROR reading from socket %d\n", n); return FAIL; } #ifdef VERBOSE @@ -1965,6 +1965,12 @@ int get_time_left(int fnum) { case PROGRESS: retval=getProgress(); break; + case ACTUAL_TIME: + retval=getActualTime(); + break; + case MEASUREMENT_TIME: + retval=getMeasurementTime(); + break; default: ret=FAIL; sprintf(mess,"timer index unknown %d\n",ind); @@ -1976,12 +1982,21 @@ int get_time_left(int fnum) { printf("get time left failed\n"); } +#ifdef VERBOSE + + printf("time left on timer %d is %lld\n",ind, retval); +#endif + n = sendDataOnly(&ret,sizeof(ret)); if (ret!=OK) { n += sendDataOnly(mess,sizeof(mess)); } else { n = sendDataOnly(&retval,sizeof(retval)); } +#ifdef VERBOSE + + printf("data sent\n"); +#endif return ret;