corrected enums, typecasted mallocs, changed eiger server to compile only in c++

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@665 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2013-09-13 07:02:15 +00:00
parent 99b0ea47b0
commit 2218a2e7e5
6 changed files with 80 additions and 71 deletions

View File

@ -8,7 +8,7 @@
#ifndef EIGER_H #ifndef EIGER_H
#define EIGER_H #define EIGER_H
#include <string.h> #include <string>
#include <vector> #include <vector>
#include "Feb.h" #include "Feb.h"

View File

@ -1,28 +1,30 @@
CC = powerpc-4xx-softfloat-gcc CC = powerpc-4xx-softfloat-gcc
CCX = powerpc-4xx-softfloat-g++ CCX = powerpc-4xx-softfloat-g++
CLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSE #-DVIRTUAL CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSE #-DVIRTUAL
LDLIBS += -lm -lstdc++ LDLIBS += -lm -lstdc++
PROGS = eigerDetectorServer PROGS = eigerDetectorServer
DESTDIR ?= bin DESTDIR ?= bin
INSTMODE = 0777 INSTMODE = 0777
SRC_CLNT = slsDetectorServer.c slsDetectorServer_funcs.c communication_funcs.c slsDetectorFunctionList.c SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
OBJS = $(SRC_CLNT:.cpp=.o) SRC_CLNT2 = Eiger.cxx HardwareIO.cxx LocalLinkInterface.cxx Feb.cxx
OBJS = $(SRC_CLNT:.c=.o)
OBJS2 = $(SRC_CLNT2:.cpp=.o)
all: clean $(PROGS) all: clean $(PROGS)
boot: $(OBJS) boot: $(OBJS) $(OBJS2)
$(PROGS): $(PROGS):
echo $(OBJS) echo $(OBJS) $(OBJS2)
mkdir -p $(DESTDIR) mkdir -p $(DESTDIR)
# $(CC) $(SRC_CLNT) $(CLAGS) $(LDLIBS) -o $@ # $(CC) $(SRC_CLNT) $(CLAGS) $(LDLIBS) -o $@
$(CC) -c $(SRC_CLNT) $(CLAGS) $(LDLIBS) $(CCX) -o $@ $(SRC_CLNT) $(SRC_CLNT2) $(CFLAGS) $(LDLIBS)
$(CCX) -o $@ slsDetectorServer.o slsDetectorServer_funcs.o communication_funcs.o slsDetectorFunctionList.o # $(CCX) -c $(SRC_CLNT) $(CLAGS) $(LDLIBS)
# $(CCX) -o $@ slsDetectorServer.o slsDetectorServer_funcs.o communication_funcs.o slsDetectorFunctionList.o
mv $(PROGS) $(DESTDIR) mv $(PROGS) $(DESTDIR)
clean: clean:

View File

@ -1,6 +1,7 @@
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
#include "slsDetectorFunctionList.h" #include "slsDetectorFunctionList.h"
#include "Eiger.h"
#include "svnInfoEiger.h" #include "svnInfoEiger.h"
#include <stdio.h> #include <stdio.h>
@ -45,12 +46,12 @@ const char* dacNames[16] = {"Svp","Svn","Vtr","Vrf","Vrs","Vtgstv","Vcmp_ll","Vc
//temporary storage on server for debugging until Ian implements //temporary storage on server for debugging until Ian implements
int dacvalues[NDAC]; int dacvalues[NDAC];
int framenum=0; int64_t framenum=0;
int trains=0; int64_t trains=0;
int exposureTime=1e6; int64_t exposureTime=(int64_t)1e6;
int period=1e9; int64_t period=(int64_t)1e9;
int delay=0; int64_t delay=0;
int gates=0; int64_t gates=0;
/** temporary /** temporary
u_int32_t CSP0BASE; u_int32_t CSP0BASE;
@ -99,11 +100,11 @@ int initializeDetectorStructure(){
#ifdef VERBOSE #ifdef VERBOSE
printf("Board is for %d modules\n",n); printf("Board is for %d modules\n",n);
#endif #endif
detectorModules=malloc(n*sizeof(sls_detector_module)); detectorModules=(sls_detector_module*)malloc(n*sizeof(sls_detector_module));
detectorChips=malloc(n*NCHIP*sizeof(int)); detectorChips=(int*)malloc(n*NCHIP*sizeof(int));
detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int)); detectorChans=(int*)malloc(n*NCHIP*NCHAN*sizeof(int));
detectorDacs=malloc(n*NDAC*sizeof(int)); detectorDacs=(dacs_t*)malloc(n*NDAC*sizeof(int));
detectorAdcs=malloc(n*NADC*sizeof(int)); detectorAdcs=(dacs_t*)malloc(n*NADC*sizeof(int));
#ifdef VERBOSE #ifdef VERBOSE
printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n)); printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n));
printf("chips from 0x%x to 0x%x\n",(unsigned int)(detectorChips), (unsigned int)(detectorChips+n*NCHIP)); printf("chips from 0x%x to 0x%x\n",(unsigned int)(detectorChips), (unsigned int)(detectorChips+n*NCHIP));
@ -311,9 +312,9 @@ int setModule(sls_detector_module myMod){
int i; int i;
for(i=0;i<myMod.ndac;i++) for(i=0;i<myMod.ndac;i++)
setDAC(i,myMod.dacs[i],myMod.module); setDAC((detDacIndex)i,myMod.dacs[i],myMod.module);
thisSettings = myMod.reg; thisSettings = (detectorSettings)myMod.reg;
return OK; return OK;
@ -343,7 +344,7 @@ int setThresholdEnergy(int thr, int imod){
enum detDacIndex setSettings(enum detDacIndex sett, int imod){ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
//template setSettings() from mcb_funcs.c //template setSettings() from mcb_funcs.c
//reads the dac registers from fpga to confirm which settings, if weird, undefined //reads the dac registers from fpga to confirm which settings, if weird, undefined
@ -453,7 +454,7 @@ int setDynamicRange(int dr){
enum readOutFlags setReadOutFlags(enum readOutFlags val){ enum readOutFlags setReadOutFlags(enum readOutFlags val){
//template setStoreInRAM from firmware_funcs.c //template setStoreInRAM from firmware_funcs.c
return -1; return GET_READOUT_FLAGS;
} }
@ -508,7 +509,7 @@ int getNumberOfADCsPerModule(){return NADC;}
enum externalSignalFlag getExtSignal(int signalindex){ enum externalSignalFlag getExtSignal(int signalindex){
//template getExtSignal from firmware_funcs.c //template getExtSignal from firmware_funcs.c
//return signals[signalindex]; //return signals[signalindex];
return -1; return GET_EXTERNAL_SIGNAL_FLAG;
} }
@ -576,7 +577,7 @@ enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){
//if( flag=SIGNAL_OFF and signals[signalindex]==MASTER_SLAVE_SYNCHRONIZATION), return -1, (ensures masterslaveflag !=off now) //if( flag=SIGNAL_OFF and signals[signalindex]==MASTER_SLAVE_SYNCHRONIZATION), return -1, (ensures masterslaveflag !=off now)
//else return flag //else return flag
int ret=GET_EXTERNAL_COMMUNICATION_MODE; enum externalCommunicationMode ret=GET_EXTERNAL_COMMUNICATION_MODE;
//sets timingmode variable //sets timingmode variable
//ensures that the signals are in acceptance with timing mode and according sets the timing mode //ensures that the signals are in acceptance with timing mode and according sets the timing mode
/* /*

View File

@ -72,7 +72,7 @@ int getChip(sls_detector_chip *myChip);
int setModule(sls_detector_module myMod); int setModule(sls_detector_module myMod);
int getModule(sls_detector_module *myMod); int getModule(sls_detector_module *myMod);
enum detDacIndex setSettings(enum detDacIndex sett, int imod); enum detectorSettings setSettings(enum detectorSettings sett, int imod);
#if defined(MYTHEND) || defined(EIGERD) #if defined(MYTHEND) || defined(EIGERD)
int getThresholdEnergy(int imod); int getThresholdEnergy(int imod);
@ -103,6 +103,7 @@ int setSpeed(enum speedVariable arg, int val);
int executeTrimming(enum trimMode mode, int par1, int par2, int imod); int executeTrimming(enum trimMode mode, int par1, int par2, int imod);
#endif #endif
#ifdef GOTTHARDD #ifdef GOTTHARDD
int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb); int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb);
int loadImage(enum imageType index, char *imageVals); int loadImage(enum imageType index, char *imageVals);

View File

@ -4,13 +4,18 @@
#include "slsDetectorServer_funcs.h" #include "slsDetectorServer_funcs.h"
#include "slsDetectorFunctionList.h" #include "slsDetectorFunctionList.h"
#include "communication_funcs.h" #include "communication_funcs.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <arpa/inet.h>
int sockfd;
extern int lockStatus;
extern char lastClientIP[INET_ADDRSTRLEN];
extern char thisClientIP[INET_ADDRSTRLEN];
extern int differentClients;
//#if defined(EIGERD) || defined(GOTTHARDD) //#if defined(EIGERD) || defined(GOTTHARDD)
//#endif //#endif
@ -35,7 +40,7 @@ const enum detectorType myDetectorType=GENERIC;
char mess[1000]; char mess[1000];
char *dataretval=NULL; char *dataretval=NULL;
int dataret; int dataret;
int dataBytes; extern int dataBytes;
@ -466,7 +471,7 @@ int set_master(int file_des) {
int set_synchronization(int file_des) { int set_synchronization(int file_des) {
enum synchronizationMode retval=GET_MASTER; enum synchronizationMode retval=GET_SYNCHRONIZATION_MODE;
enum synchronizationMode arg; enum synchronizationMode arg;
int n; int n;
int ret=OK; int ret=OK;
@ -532,7 +537,7 @@ int get_detector_type(int file_des) {
/* send answer */ /* send answer */
/* send OK/failed */ /* send OK/failed */
if (differentClients==1) if (differentClients==1)
retval=FORCE_UPDATE; ret=FORCE_UPDATE;
n += sendData(file_des,&ret,sizeof(ret),INT32); n += sendData(file_des,&ret,sizeof(ret),INT32);
if (ret!=FAIL) { if (ret!=FAIL) {
@ -566,7 +571,7 @@ int set_number_of_modules(int file_des) {
} }
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) { if (ret==OK) {
dim=arg[0]; dim=(dimension)arg[0];
nm=arg[1]; nm=arg[1];
/* execute action */ /* execute action */
@ -675,7 +680,7 @@ int set_external_signal_flag(int file_des) {
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) { if (ret==OK) {
signalindex=arg[0]; signalindex=arg[0];
flag=arg[1]; flag=(externalSignalFlag)arg[1];
/* execute action */ /* execute action */
switch (flag) { switch (flag) {
case GET_EXTERNAL_SIGNAL_FLAG: case GET_EXTERNAL_SIGNAL_FLAG:
@ -991,7 +996,7 @@ int set_dac(int file_des) {
int imod; int imod;
int n; int n;
int val; int val;
enum detDacIndex idac=0; enum detDacIndex idac=(detDacIndex)0;
sprintf(mess,"Can't set DAC\n"); sprintf(mess,"Can't set DAC\n");
@ -1001,7 +1006,7 @@ int set_dac(int file_des) {
sprintf(mess,"Error reading from socket\n"); sprintf(mess,"Error reading from socket\n");
ret=FAIL; ret=FAIL;
} }
ind=arg[0]; ind=(dacIndex)arg[0];
imod=arg[1]; imod=arg[1];
n = receiveData(file_des,&val,sizeof(val),INT32); n = receiveData(file_des,&val,sizeof(val),INT32);
@ -1055,52 +1060,52 @@ int set_dac(int file_des) {
#endif #endif
#ifdef EIGERD #ifdef EIGERD
case E_SvP: case E_SvP:
ind = SVP; idac = (detDacIndex)SVP;
break; break;
case E_SvN: case E_SvN:
ind = SVN; idac = (detDacIndex)SVN;
break; break;
case E_Vtr: case E_Vtr:
idac = VTR; idac = (detDacIndex)VTR;
break; break;
case E_Vrf: case E_Vrf:
idac = VRF; idac = (detDacIndex)VRF;
break; break;
case E_Vrs: case E_Vrs:
idac = VRS; idac = (detDacIndex)VRS;
break; break;
case E_Vtgstv: case E_Vtgstv:
idac = VTGSTV; idac = (detDacIndex)VTGSTV;
break; break;
case E_Vcmp_ll: case E_Vcmp_ll:
idac = VCMP_LL; idac = (detDacIndex)VCMP_LL;
break; break;
case E_Vcmp_lr: case E_Vcmp_lr:
idac = VCMP_LR; idac = (detDacIndex)VCMP_LR;
break; break;
case E_cal: case E_cal:
idac = CAL; idac = (detDacIndex)CAL;
break; break;
case E_Vcmp_rl: case E_Vcmp_rl:
idac = VCMP_RL; idac = (detDacIndex)VCMP_RL;
break; break;
case E_Vcmp_rr: case E_Vcmp_rr:
idac = VCMP_RR; idac = (detDacIndex)VCMP_RR;
break; break;
case E_rxb_rb: case E_rxb_rb:
idac = RXB_RB; idac = (detDacIndex)RXB_RB;
break; break;
case E_rxb_lb: case E_rxb_lb:
idac = RXB_LB; idac = (detDacIndex)RXB_LB;
break; break;
case E_Vcp: case E_Vcp:
idac = VCP; idac = (detDacIndex)VCP;
break; break;
case E_Vcn: case E_Vcn:
idac = VCN; idac = (detDacIndex)VCN;
break; break;
case E_Vis: case E_Vis:
idac = VIS; idac = (detDacIndex)VIS;
break; break;
#endif #endif
default: default:
@ -1163,6 +1168,7 @@ int get_adc(int file_des) {
enum dacIndex ind; enum dacIndex ind;
int imod; int imod;
int n; int n;
enum detDacIndex idac=(detDacIndex)0;
sprintf(mess,"Can't read ADC\n"); sprintf(mess,"Can't read ADC\n");
@ -1172,7 +1178,7 @@ int get_adc(int file_des) {
sprintf(mess,"Error reading from socket\n"); sprintf(mess,"Error reading from socket\n");
ret=FAIL; ret=FAIL;
} }
ind=arg[0]; ind=(dacIndex)arg[0];
imod=arg[1]; imod=arg[1];
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
@ -1184,7 +1190,7 @@ int get_adc(int file_des) {
switch (ind) { switch (ind) {
#ifdef GOTTHARDD #ifdef GOTTHARDD
case TEMPERATURE_FPGA: //ind = TEMP_FPGA; case TEMPERATURE_FPGA: //dac = (detDacIndex)TEMP_FPGA;
break; break;
case TEMPERATURE_ADC: case TEMPERATURE_ADC:
break; break;
@ -1197,18 +1203,18 @@ int get_adc(int file_des) {
} }
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) { if (ret==OK) {
retval=getADC(ind,imod); retval=getADC(idac,imod);
} }
#endif #endif
#ifdef VERBOSE #ifdef VERBOSE
printf("Getting ADC %d of module %d\n", ind, imod); printf("Getting ADC %d of module %d\n", idac, imod);
#endif #endif
#ifdef VERBOSE #ifdef VERBOSE
printf("ADC is %f V\n", retval); printf("ADC is %f V\n", retval);
#endif #endif
if (ret==FAIL) { if (ret==FAIL) {
printf("Getting adc %d of module %d failed\n", ind, imod); printf("Getting adc %d of module %d failed\n", idac, imod);
} }
@ -1518,7 +1524,7 @@ int set_chip(int file_des) {
sls_detector_chip myChip; sls_detector_chip myChip;
myChip.nchan=getNumberOfChannelsPerChip(); myChip.nchan=getNumberOfChannelsPerChip();
ch=malloc((myChip.nchan)*sizeof(int)); ch=(int*)malloc((myChip.nchan)*sizeof(int));
myChip.chanregs=ch; myChip.chanregs=ch;
@ -1598,7 +1604,7 @@ int get_chip(int file_des) {
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
retval.nchan=getNumberOfChannelsPerChip(); retval.nchan=getNumberOfChannelsPerChip();
ch=malloc((retval.nchan)*sizeof(int)); ch=(int*)malloc((retval.nchan)*sizeof(int));
retval.chanregs=ch; retval.chanregs=ch;
#endif #endif
@ -1663,10 +1669,10 @@ int set_module(int file_des) {
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
sls_detector_module myModule; sls_detector_module myModule;
int *myChip=malloc(getNumberOfChipsPerModule()*sizeof(int)); int *myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int));
int *myChan=malloc(getNumberOfChannelsPerModule()*sizeof(int)); int *myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int));
int *myDac=malloc(getNumberOfDACsPerModule()*sizeof(int)); int *myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int));
int *myAdc=malloc(getNumberOfADCsPerModule()*sizeof(int)); int *myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int));
if (myDac) if (myDac)
@ -1763,10 +1769,10 @@ int get_module(int file_des) {
sls_detector_module myModule; sls_detector_module myModule;
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
int *myChip=malloc(getNumberOfChipsPerModule()*sizeof(int)); int *myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int));
int *myChan=malloc(getNumberOfChannelsPerModule()*sizeof(int)); int *myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int));
int *myDac=malloc(getNumberOfDACsPerModule()*sizeof(int)); int *myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int));
int *myAdc=malloc(getNumberOfADCsPerModule()*sizeof(int)); int *myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int));
if (myDac) if (myDac)
@ -1868,7 +1874,7 @@ int set_settings(int file_des) {
ret=FAIL; ret=FAIL;
} }
imod=arg[1]; imod=arg[1];
isett=arg[0]; isett=(detectorSettings)arg[0];
printf("isett:%d, imod =%d\n",isett,imod); printf("isett:%d, imod =%d\n",isett,imod);
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
@ -1990,7 +1996,7 @@ int set_threshold_energy(int file_des) {
#if defined(MYTHEND) || defined(EIGERD) #if defined(MYTHEND) || defined(EIGERD)
ethr=arg[0]; ethr=arg[0];
imod=arg[1]; imod=arg[1];
isett=arg[2]; isett=(detectorSettings)arg[2];
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
if (imod>=getTotalNumberOfModules()) { if (imod>=getTotalNumberOfModules()) {
ret=FAIL; ret=FAIL;
@ -2559,7 +2565,7 @@ int set_roi(int file_des) {
n = receiveData(file_des,&arg[i].ymax,sizeof(int),INT32); n = receiveData(file_des,&arg[i].ymax,sizeof(int),INT32);
} }
//n = receiveData(file_des,arg,nroi*sizeof(ROI)); //n = receiveData(file_des,arg,nroi*sizeof(ROI));
if (n != (nroi*sizeof(ROI))) { if ((unsigned int)n != (nroi*sizeof(ROI))) {
sprintf(mess,"Received wrong number of bytes for ROI\n"); sprintf(mess,"Received wrong number of bytes for ROI\n");
ret=FAIL; ret=FAIL;
} }
@ -2699,7 +2705,7 @@ int execute_trimming(int file_des) {
int arg[3]; int arg[3];
int n; int n;
int ret=OK, retval; int ret=OK, retval=0;
#if defined(MYTHEND) || defined(EIGERD) #if defined(MYTHEND) || defined(EIGERD)
int imod, par1,par2; int imod, par1,par2;
#endif #endif

View File

@ -8,7 +8,6 @@
int sockfd;
//basic server functions //basic server functions