mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
got rid of many warnings and load darkimage and reset/read counter works now
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@158 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
ca896b8b30
commit
410725784c
@ -5,7 +5,7 @@
|
||||
|
||||
CROSS = bfin-uclinux-
|
||||
CC = $(CROSS)gcc
|
||||
CFLAGS += -Wall -DMCB_FUNCS -DVERBOSE #-DVERYVERBOSE #-DVIRTUAL
|
||||
CFLAGS += -Wall -DMCB_FUNCS -DVERBOSE -DVERYVERBOSE #-DVIRTUAL
|
||||
|
||||
|
||||
PROGS= gotthardDetectorServer
|
||||
|
@ -21,7 +21,7 @@ FILE *debugfp, *datafp;
|
||||
int fr;
|
||||
int wait_time;
|
||||
int *fifocntrl;
|
||||
volatile const u_int16_t *values;
|
||||
|
||||
//int *statusreg; commented out by dhanya
|
||||
const int nModY=1;
|
||||
int nModBoard;
|
||||
@ -29,8 +29,10 @@ int nModX=NMAXMOD;
|
||||
int dynamicRange=16;//32;
|
||||
int dataBytes=NMAXMOD*NCHIP*NCHAN*2;
|
||||
int storeInRAM=0;
|
||||
volatile u_int32_t *ram_values=NULL;
|
||||
|
||||
u_int32_t *ram_values=NULL;
|
||||
volatile char *now_ptr=NULL;
|
||||
volatile u_int16_t *values;
|
||||
int ram_size=0;
|
||||
|
||||
int64_t totalTime=1;
|
||||
@ -48,8 +50,8 @@ enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_
|
||||
#ifdef MCB_FUNCS
|
||||
extern const int nChans;
|
||||
extern const int nChips;
|
||||
extern const int nDacs;
|
||||
extern const int nAdcs;
|
||||
//extern const int nDacs;
|
||||
//extern const int nAdcs;
|
||||
#endif
|
||||
#ifndef MCB_FUNCS
|
||||
|
||||
@ -60,7 +62,7 @@ const int nAdcs=NADC;
|
||||
#endif
|
||||
|
||||
|
||||
int dacVals[NDAC];
|
||||
|
||||
|
||||
/**
|
||||
ENEt conf structs
|
||||
@ -216,7 +218,7 @@ u_int32_t bus_r(u_int32_t offset) {
|
||||
|
||||
int setPhaseShiftOnce(){
|
||||
u_int32_t addr, reg;
|
||||
int result=OK, i,val;
|
||||
int result=OK, i;
|
||||
addr=MULTI_PURPOSE_REG;
|
||||
reg=bus_r(addr);
|
||||
#ifdef VERBOSE
|
||||
@ -232,7 +234,7 @@ int setPhaseShiftOnce(){
|
||||
//phase shift
|
||||
for (i=1;i<PHASE_SHIFT;i++) {
|
||||
bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT|PHASE_STEP_BIT));//0x2821
|
||||
bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT&~PHASE_STEP_BIT));//0x2820
|
||||
bus_w(addr,(INT_RSTN_BIT|ENET_RESETN_BIT|(SW1_BIT&~PHASE_STEP_BIT)));//0x2820
|
||||
}
|
||||
}
|
||||
reg=bus_r(addr);
|
||||
@ -425,6 +427,7 @@ u_int32_t setExtSignal(int d, enum externalSignalFlag mode) {
|
||||
break;
|
||||
default:
|
||||
setFPGASignal(d,mode);
|
||||
break;
|
||||
}
|
||||
|
||||
setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
||||
@ -600,7 +603,7 @@ int setTiming(int ti) {
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
@ -652,7 +655,7 @@ int setConfigurationRegister(int d) {
|
||||
}
|
||||
|
||||
int setToT(int d) {
|
||||
int ret=0;
|
||||
//int ret=0;
|
||||
int reg;
|
||||
#ifdef VERBOSE
|
||||
printf("Setting ToT to %d\n",d);
|
||||
@ -677,7 +680,7 @@ int setToT(int d) {
|
||||
}
|
||||
|
||||
int setContinousReadOut(int d) {
|
||||
int ret=0;
|
||||
//int ret=0;
|
||||
int reg;
|
||||
#ifdef VERBOSE
|
||||
printf("Setting Continous readout to %d\n",d);
|
||||
@ -762,7 +765,6 @@ u_int32_t testFpga(void) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
//dummy register
|
||||
addr = DUMMY_REG;
|
||||
for(i=0;i<1000000;i++)
|
||||
@ -813,7 +815,7 @@ u_int32_t testRAM(void) {
|
||||
allocateRAM();
|
||||
// while(i<100000) {
|
||||
memcpy(ram_values, values, dataBytes);
|
||||
printf ("Test RAM:\t%d: copied fifo %x to memory %x size %d\n",i++, values, ram_values, dataBytes);
|
||||
printf ("Test RAM:\t%d: copied fifo %x to memory %x size %d\n",i++, (unsigned int)(values), (unsigned int)(ram_values), dataBytes);
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
@ -832,7 +834,9 @@ int getNModBoard() {
|
||||
|
||||
int setNMod(int n) {
|
||||
|
||||
int fifo;
|
||||
|
||||
/* commented out by dhanya
|
||||
// int fifo;
|
||||
// int ifsta, ifsto, ifste;
|
||||
int imod;
|
||||
int rval;
|
||||
@ -856,6 +860,7 @@ int setNMod(int n) {
|
||||
break;
|
||||
default:
|
||||
shiftfifo=SHIFTFIFO;
|
||||
break;
|
||||
}
|
||||
} else
|
||||
shiftfifo=SHIFTFIFO;
|
||||
@ -867,7 +872,7 @@ int setNMod(int n) {
|
||||
if (n>0 && n<=ntot) {
|
||||
nModX=n;
|
||||
|
||||
/*d isable the fifos relative to the unused modules */
|
||||
//d isable the fifos relative to the unused modules
|
||||
for (ififo=0; ififo<ntot*NCHIP; ififo++) {
|
||||
reg=bus_r(FIFO_COUNTR_REG_OFF+(ififo<<shiftfifo));
|
||||
if (ififo<n*NCHIP) {
|
||||
@ -938,7 +943,7 @@ int setNMod(int n) {
|
||||
printf("There are %d modules enabled (%d fifos)\n",nModX, nf);
|
||||
#endif
|
||||
getDynamicRange();
|
||||
|
||||
*/
|
||||
return nModX;
|
||||
}
|
||||
|
||||
@ -947,6 +952,7 @@ int setNMod(int n) {
|
||||
u_int32_t testFifos(void) {
|
||||
printf("Fifo test not implemented!\n");
|
||||
bus_w(CONTROL_REG, START_FIFOTEST_BIT);
|
||||
bus_w(CONTROL_REG, 0x0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1062,6 +1068,7 @@ int64_t setProbes(int64_t value){
|
||||
break;
|
||||
default:
|
||||
ow=1;
|
||||
break;
|
||||
}
|
||||
if (value>=0) {
|
||||
setCSregister(ALLMOD);
|
||||
@ -1078,6 +1085,8 @@ int64_t setProgress() {
|
||||
|
||||
//????? eventually call after setting the registers
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1086,6 +1095,7 @@ int64_t getProgress() {
|
||||
|
||||
//should be done in firmware!!!!
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@ -1120,11 +1130,16 @@ int loadImage(int index, short int ImageVals[]){
|
||||
}
|
||||
volatile u_int16_t *ptr;
|
||||
ptr=(u_int16_t*)(CSP0BASE+address*2);
|
||||
memcpy(ptr,ImageVals ,2560);
|
||||
#ifdef VERBOSE
|
||||
printf("Loaded x%08x address with image of index %d\n",ptr,index);
|
||||
int i;
|
||||
for(i=0;i<6;i++)
|
||||
printf("%d:%d\t",i,ImageVals[i]);
|
||||
#endif
|
||||
return 0;
|
||||
memcpy(ptr,ImageVals ,dataBytes);
|
||||
#ifdef VERBOSE
|
||||
printf("\nLoaded x%08x address with image of index %d\n",(unsigned int)(ptr),index);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@ -1177,7 +1192,6 @@ int setDACRegister(int idac, int val, int imod) {
|
||||
mask=~((0x3ff)<<off);
|
||||
|
||||
if (val>=0 && val<DAC_DR) {
|
||||
dacVals[idac];
|
||||
reg=bus_r(addr+(imod<<SHIFTMOD));
|
||||
reg&=mask;
|
||||
reg|=(val<<off);
|
||||
@ -1198,20 +1212,20 @@ float getTemperature(int tempSensor, int imod){
|
||||
float val;
|
||||
char cTempSensor[2][100]={"ADCs/ASICs","VRs/FPGAs"};
|
||||
imod=0;//ignoring more than 1 mod for now
|
||||
int i,j,k,repeats=6;
|
||||
u_int32_t tempVal=0,tempVal2=0;
|
||||
int i,j,repeats=6;
|
||||
u_int32_t tempVal=0;
|
||||
#ifdef VERBOSE
|
||||
printf("Getting Temperature of module:%d for the %s for tempsensor:%d\n",imod,cTempSensor[tempSensor],tempSensor);
|
||||
#endif
|
||||
bus_w(TEMP_IN_REG,(T1_CLK_BIT)|(T1_CS_BIT)|(T2_CLK_BIT)|(T2_CS_BIT));//standby
|
||||
bus_w(TEMP_IN_REG,(T1_CLK_BIT)&~(T1_CS_BIT)|(T2_CLK_BIT));//high clk low cs
|
||||
bus_w(TEMP_IN_REG,((T1_CLK_BIT)&~(T1_CS_BIT))|(T2_CLK_BIT));//high clk low cs
|
||||
|
||||
for(i=0;i<20;i++) {
|
||||
//repeats is number of register writes for delay
|
||||
for(j=0;j<repeats;j++)
|
||||
bus_w(TEMP_IN_REG,~(T1_CLK_BIT)&~(T1_CS_BIT)&~(T2_CLK_BIT)&~(T2_CS_BIT));//low clk low cs
|
||||
for(j=0;j<repeats;j++)
|
||||
bus_w(TEMP_IN_REG,(T1_CLK_BIT)&~(T1_CS_BIT)|(T2_CLK_BIT));//high clk low cs
|
||||
bus_w(TEMP_IN_REG,((T1_CLK_BIT)&~(T1_CS_BIT))|(T2_CLK_BIT));//high clk low cs
|
||||
|
||||
if(i<=10){//only the first time
|
||||
if(!tempSensor)
|
||||
@ -1435,7 +1449,7 @@ int configureMAC(int ipad,long long int macad,long long int servermacad,int ival
|
||||
checksum = (~sum)&0xffff;
|
||||
mac_conf_regs->ip.ip_chksum = checksum;
|
||||
//#ifdef VERBOSE
|
||||
printf("IP header checksum is 0x%x s\n",checksum);
|
||||
printf("IP header checksum is 0x%x s\n",(unsigned int)(checksum));
|
||||
//#endif
|
||||
|
||||
mac_conf_regs->udp.udp_srcport = 0xE185;
|
||||
@ -1533,12 +1547,15 @@ u_int32_t startStateMachine(){
|
||||
write_stop_sm(0);
|
||||
write_status_sm("Started");
|
||||
#endif
|
||||
/*
|
||||
#ifdef MCB_FUNCS
|
||||
// setCSregister(ALLMOD);
|
||||
setCSregister(ALLMOD);
|
||||
clearSSregister(ALLMOD);
|
||||
#endif
|
||||
putout("0000000000000000",ALLMOD);
|
||||
*/
|
||||
//putout("0000000000000000",ALLMOD);
|
||||
bus_w(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
|
||||
bus_w(CONTROL_REG, 0x0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1555,6 +1572,7 @@ u_int32_t stopStateMachine(){
|
||||
write_status_sm("Stopped");
|
||||
#endif
|
||||
bus_w(CONTROL_REG, STOP_ACQ_BIT);
|
||||
bus_w(CONTROL_REG, 0x0);
|
||||
usleep(500);
|
||||
// if (!runBusy())
|
||||
if(!(bus_r(STATUS_REG)&RUNMACHINE_BUSY_BIT))
|
||||
@ -1574,6 +1592,7 @@ u_int32_t startReadOut(){
|
||||
printf("State machine status is %08x\n",bus_r(STATUS_REG));
|
||||
#endif
|
||||
bus_w(CONTROL_REG, START_ACQ_BIT |START_READOUT_BIT); // start readout
|
||||
bus_w(CONTROL_REG, 0x0);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1620,6 +1639,7 @@ u_int32_t fifoReadCounter(int fifonum)
|
||||
break;
|
||||
default:
|
||||
shiftfifo=SHIFTFIFO;
|
||||
break;
|
||||
}
|
||||
|
||||
rval=bus_r(FIFO_COUNTR_REG_OFF+(fifonum<<shiftfifo));
|
||||
@ -1707,7 +1727,7 @@ u_int32_t* fifo_read_event()
|
||||
//memcpy(now_ptr, values, dataBytes);
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
printf("Copying to ptr %08x %d\n",now_ptr, dataBytes);
|
||||
printf("Copying to ptr %08x %d\n",(unsigned int)(now_ptr), dataBytes);
|
||||
printf("after readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
|
||||
#endif
|
||||
|
||||
@ -1722,13 +1742,13 @@ u_int32_t* fifo_read_event()
|
||||
u_int32_t* decode_data(int *datain)
|
||||
{
|
||||
u_int32_t *dataout;
|
||||
const char one=1;
|
||||
// const char one=1;
|
||||
const int bytesize=8;
|
||||
char *ptr=(char*)datain;
|
||||
//int nbits=dynamicRange;
|
||||
int ipos=0, ichan=0;;
|
||||
//int nch, boff=0;
|
||||
int ibyte, ibit;
|
||||
int ibyte;//, ibit;
|
||||
char iptr;
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -1772,6 +1792,7 @@ u_int32_t* decode_data(int *datain)
|
||||
default:
|
||||
for (ichan=0; ichan<nChans*nChips*nModX; ichan++)
|
||||
dataout[ichan]=datain[ichan]&0xffffff;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -1873,7 +1894,7 @@ int getDynamicRange() {
|
||||
int testBus() {
|
||||
u_int32_t j;
|
||||
u_int64_t i, n, nt;
|
||||
char cmd[100];
|
||||
// char cmd[100];
|
||||
u_int32_t val=0x0;
|
||||
int ifail=OK;
|
||||
// printf("%s\n",cmd);
|
||||
@ -1882,7 +1903,7 @@ int testBus() {
|
||||
|
||||
n=1000000;
|
||||
nt=n/100;
|
||||
printf("testing bus %d times\n",n);
|
||||
printf("testing bus %d times\n",(int)n);
|
||||
while (i<n) {
|
||||
// val=bus_r(FIX_PATT_REG);
|
||||
bus_w(DUMMY_REG,val);
|
||||
@ -1890,7 +1911,7 @@ int testBus() {
|
||||
j=bus_r(DUMMY_REG);
|
||||
//if (i%10000==1)
|
||||
if (j!=val){
|
||||
printf("%d : read wrong value %08x instead of %08x\n",i,j, val);
|
||||
printf("%d : read wrong value %08x instead of %08x\n",(int)i,j, val);
|
||||
ifail++;
|
||||
//return FAIL;
|
||||
}// else
|
||||
@ -1929,13 +1950,13 @@ int allocateRAM() {
|
||||
size=dataBytes;
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("\nnmodx=%d nmody=%d dynamicRange=%d dataBytes=%d nFrames=%d nTrains=%d, size=%d\n",nModX,nModY,dynamicRange,dataBytes,nf,nt,size );
|
||||
printf("\nnmodx=%d nmody=%d dynamicRange=%d dataBytes=%d nFrames=%d nTrains=%d, size=%d\n",nModX,nModY,dynamicRange,dataBytes,nf,nt,(int)size );
|
||||
#endif
|
||||
|
||||
if (size==ram_size) {
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("RAM of size %d already allocated: nothing to be done\n", size);
|
||||
printf("RAM of size %d already allocated: nothing to be done\n",(int) size);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
@ -1943,7 +1964,7 @@ int allocateRAM() {
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("reallocating ram %x\n",ram_values);
|
||||
printf("reallocating ram %x\n",(unsigned int)ram_values);
|
||||
#endif
|
||||
// clearRAM();
|
||||
// ram_values=malloc(size);
|
||||
@ -1953,12 +1974,12 @@ int allocateRAM() {
|
||||
if (ram_values) {
|
||||
now_ptr=(char*)ram_values;
|
||||
#ifdef VERBOSE
|
||||
printf("ram allocated 0x%x of size %d to %x\n",now_ptr, size, now_ptr+size);
|
||||
printf("ram allocated 0x%x of size %d to %x\n",(int)now_ptr,(unsigned int) size,(unsigned int)(now_ptr+size));
|
||||
#endif
|
||||
ram_size=size;
|
||||
return OK;
|
||||
} else {
|
||||
printf("could not allocate %d bytes\n",size);
|
||||
printf("could not allocate %d bytes\n",(int)size);
|
||||
if (storeInRAM==1) {
|
||||
printf("retrying\n");
|
||||
storeInRAM=0;
|
||||
@ -1970,7 +1991,7 @@ int allocateRAM() {
|
||||
now_ptr=(char*)ram_values;
|
||||
ram_size=size;
|
||||
#ifdef VERBOSE
|
||||
printf("ram allocated 0x%x of size %d to %x\n",now_ptr, size, now_ptr+size);
|
||||
printf("ram allocated 0x%x of size %d to %x\n",(int)now_ptr,(unsigned int) size,(unsigned int)(now_ptr+size));
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
@ -2066,7 +2087,7 @@ int setMaster(int f) {
|
||||
break;
|
||||
default:
|
||||
//do nothing
|
||||
;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(masterMode) {
|
||||
@ -2101,6 +2122,7 @@ int setMaster(int f) {
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IS_SLAVE:
|
||||
for (i=0; i<4; i++) {
|
||||
@ -2124,6 +2146,7 @@ int setMaster(int f) {
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return masterMode;
|
||||
}
|
||||
@ -2187,7 +2210,7 @@ int setSynchronization(int s) {
|
||||
|
||||
default:
|
||||
//do nothing
|
||||
;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (syncMode) {
|
||||
@ -2237,3 +2260,137 @@ int setSynchronization(int s) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int readCounterBlock(int startACQ, short int CounterVals[]){
|
||||
|
||||
//char *counterVals=NULL;
|
||||
//counterVals=realloc(counterVals,dataBytes);
|
||||
|
||||
u_int32_t val;
|
||||
volatile u_int16_t *ptr;
|
||||
int i;
|
||||
|
||||
u_int32_t address = COUNTER_MEMORY_REG;
|
||||
ptr=(u_int16_t*)(CSP0BASE+address*2);
|
||||
|
||||
|
||||
if (runBusy()) {
|
||||
if(stopStateMachine()==FAIL)
|
||||
return FAIL;
|
||||
//waiting for the last frame read to be done
|
||||
while(runBusy()) usleep(500);
|
||||
#ifdef VERBOSE
|
||||
printf("State machine stopped\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
val=bus_r(MULTI_PURPOSE_REG);
|
||||
#ifdef VERBOSE
|
||||
printf("Value of multipurpose reg:%d\n",bus_r(MULTI_PURPOSE_REG));
|
||||
#endif
|
||||
|
||||
memcpy(CounterVals,ptr,dataBytes);
|
||||
#ifdef VERBOSE
|
||||
printf("Copied counter memory block with size of %d bytes..\n",dataBytes);
|
||||
for(i=0;i<6;i++)
|
||||
printf("%d: %d\t",i,CounterVals[i]);
|
||||
#endif
|
||||
|
||||
|
||||
bus_w(MULTI_PURPOSE_REG,(val&~RESET_COUNTER_BIT));
|
||||
#ifdef VERBOSE
|
||||
printf("\nClearing bit 2 of multipurpose reg:%d\n",bus_r(MULTI_PURPOSE_REG));
|
||||
#endif
|
||||
|
||||
if(startACQ==1){
|
||||
startStateMachine();
|
||||
if(runBusy())
|
||||
printf("State machine RUNNING\n");
|
||||
else
|
||||
printf("State machine IDLE\n");
|
||||
}
|
||||
|
||||
/* if(sizeof(CounterVals)<=0){
|
||||
printf("ERROR:size of counterVals=%d\n",(int)sizeof(CounterVals));
|
||||
return FAIL;
|
||||
}*/
|
||||
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int resetCounterBlock(int startACQ){
|
||||
|
||||
char *counterVals=NULL;
|
||||
counterVals=realloc(counterVals,dataBytes);
|
||||
|
||||
int ret = OK;
|
||||
u_int32_t val;
|
||||
volatile u_int16_t *ptr;
|
||||
int i;
|
||||
|
||||
|
||||
u_int32_t address = COUNTER_MEMORY_REG;
|
||||
ptr=(u_int16_t*)(CSP0BASE+address*2);
|
||||
|
||||
|
||||
if (runBusy()) {
|
||||
if(stopStateMachine()==FAIL)
|
||||
return FAIL;
|
||||
//waiting for the last frame read to be done
|
||||
while(runBusy()) usleep(500);
|
||||
#ifdef VERBOSE
|
||||
printf("State machine stopped\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
val=bus_r(MULTI_PURPOSE_REG);
|
||||
#ifdef VERBOSE
|
||||
printf("Value of multipurpose reg:%d\n",bus_r(MULTI_PURPOSE_REG));
|
||||
#endif
|
||||
|
||||
|
||||
bus_w(MULTI_PURPOSE_REG,(val|RESET_COUNTER_BIT));
|
||||
#ifdef VERBOSE
|
||||
printf("Setting bit 2 of multipurpose reg:%d\n",bus_r(MULTI_PURPOSE_REG));
|
||||
#endif
|
||||
|
||||
|
||||
memcpy(counterVals,ptr,dataBytes);
|
||||
#ifdef VERBOSE
|
||||
printf("Copied counter memory block with size of %d bytes..\n",(int)sizeof(counterVals));
|
||||
for(i=0;i<6;i=i+2)
|
||||
printf("%d: %d\t",i,*(counterVals+i));
|
||||
#endif
|
||||
|
||||
|
||||
bus_w(MULTI_PURPOSE_REG,(val&~RESET_COUNTER_BIT));
|
||||
#ifdef VERBOSE
|
||||
printf("\nClearing bit 2 of multipurpose reg:%d\n",bus_r(MULTI_PURPOSE_REG));
|
||||
#endif
|
||||
|
||||
if(startACQ==1){
|
||||
startStateMachine();
|
||||
if(runBusy())
|
||||
printf("State machine RUNNING\n");
|
||||
else
|
||||
printf("State machine IDLE\n");
|
||||
}
|
||||
|
||||
if(sizeof(counterVals)<=0){
|
||||
printf("ERROR:size of counterVals=%d\n",(int)sizeof(counterVals));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -38,8 +38,8 @@ u_int32_t setWaitStates(int d);
|
||||
u_int32_t getWaitStates();
|
||||
u_int32_t setTotClockDivider(int d);
|
||||
u_int32_t getTotClockDivider();
|
||||
u_int32_t setTotClockDutyCycle(int d);
|
||||
u_int32_t getTotClockDutyCycle();
|
||||
u_int32_t setTotDutyCycle(int d);
|
||||
u_int32_t getTotDutyCycle();
|
||||
|
||||
u_int32_t setExtSignal(int d, enum externalSignalFlag mode);
|
||||
int getExtSignal(int d);
|
||||
@ -83,7 +83,7 @@ int64_t setGates(int64_t value);
|
||||
int64_t getGates();
|
||||
|
||||
int64_t setDelay(int64_t value);
|
||||
int64_t getDelaye();
|
||||
int64_t getDelay();
|
||||
|
||||
int64_t setPeriod(int64_t value);
|
||||
int64_t getPeriod();
|
||||
@ -100,7 +100,6 @@ int64_t setProgress();
|
||||
int64_t getActualTime();
|
||||
int64_t getMeasurementTime();
|
||||
|
||||
int loadImage(int index, short int ImageVals[]);
|
||||
|
||||
u_int32_t runBusy(void);
|
||||
u_int32_t runState(void);
|
||||
@ -134,6 +133,9 @@ int clearRAM();
|
||||
int setMaster(int f);
|
||||
int setSynchronization(int s);
|
||||
|
||||
int loadImage(int index, short int ImageVals[]);
|
||||
int readCounterBlock(int startACQ, short int CounterVals[]);
|
||||
int resetCounterBlock(int startACQ);
|
||||
/*
|
||||
|
||||
u_int32_t setNBits(u_int32_t);
|
||||
|
@ -20,7 +20,7 @@
|
||||
#undef DEBUGOUT
|
||||
|
||||
extern int nModX;
|
||||
extern int dataBytes;
|
||||
//extern int dataBytes;
|
||||
extern int dynamicRange;
|
||||
const int nChans=NCHAN;
|
||||
const int nChips=NCHIP;
|
||||
@ -59,11 +59,11 @@ int initDetector() {
|
||||
detectorDacs=malloc(n*NDAC*sizeof(float));
|
||||
detectorAdcs=malloc(n*NADC*sizeof(float));
|
||||
#ifdef VERBOSE
|
||||
printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n);
|
||||
printf("chips from 0x%x to 0x%x\n",detectorChips, detectorChips+n*NCHIP);
|
||||
printf("chans from 0x%x to 0x%x\n",detectorChans, detectorChans+n*NCHIP*NCHAN);
|
||||
printf("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs+n*NDAC);
|
||||
printf("adcs from 0x%x to 0x%x\n",detectorAdcs, detectorAdcs+n*NADC);
|
||||
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("chans from 0x%x to 0x%x\n",(unsigned int)(detectorChans), (unsigned int)(detectorChans+n*NCHIP*NCHAN));
|
||||
printf("dacs from 0x%x to 0x%x\n",(unsigned int)(detectorDacs), (unsigned int)(detectorDacs+n*NDAC));
|
||||
printf("adcs from 0x%x to 0x%x\n",(unsigned int)(detectorAdcs), (unsigned int)(detectorAdcs+n*NADC));
|
||||
#endif
|
||||
for (imod=0; imod<n; imod++) {
|
||||
|
||||
@ -151,7 +151,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
int ret=OK;
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Copying module %x to module %x\n",srcMod,destMod);
|
||||
printf("Copying module %x to module %x\n",(unsigned int)(srcMod),(unsigned int)(destMod));
|
||||
#endif
|
||||
|
||||
if (srcMod->module>=0) {
|
||||
@ -480,7 +480,7 @@ int program_one_dac(int addr, int value, int imod) {
|
||||
if (imod>=0 && imod<nModX) {
|
||||
detectorDacs[idac+NDAC*imod]=v;
|
||||
#ifdef VERBOSE
|
||||
printf("module=%d index=%d, val=%d addr=%x\n",imod, idac, v, detectorDacs+idac+NDAC*imod);
|
||||
printf("module=%d index=%d, val=%d addr=%x\n",imod, idac, v, (unsigned int)(detectorDacs+idac+NDAC*imod));
|
||||
#endif
|
||||
|
||||
setDACRegister(idac,v,imod);
|
||||
@ -564,7 +564,7 @@ float initDACbyIndexDACU(int ind, int val, int imod) {
|
||||
|
||||
// int cs=daccs[ind];
|
||||
// int addr=dacaddr[ind];
|
||||
int iv;
|
||||
// int iv;
|
||||
int im;
|
||||
|
||||
if (val>=0)
|
||||
@ -604,7 +604,7 @@ int getThresholdEnergy() {
|
||||
float g[3]=DEFAULTGAIN;
|
||||
float o[3]=DEFAULTOFFSET;
|
||||
float myg=-1, myo=-1;
|
||||
int dacu;
|
||||
// int dacu;
|
||||
int imod;
|
||||
int ethr=-1;
|
||||
int ret=FAIL;
|
||||
@ -643,7 +643,7 @@ int getThresholdEnergy() {
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
//printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo, detectorDacs[VTHRESH+imod*NDAC]);
|
||||
printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo,setDACRegister(VREF_DS,-1,imod));//edited by dhanya
|
||||
printf("module=%d gain=%f, offset=%f, dacu=%f\n",imod, myg, myo,(float)(setDACRegister(VREF_DS,-1,imod)));//edited by dhanya
|
||||
printf("Threshold energy of module %d is %d eV\n", imod, ethr);
|
||||
#endif
|
||||
|
||||
@ -700,7 +700,7 @@ int setThresholdEnergy(int ethr) {
|
||||
if (myg>0 && myo>0) {
|
||||
dacu=myo-myg*((float)ethr)/1000.;
|
||||
#ifdef VERBOSE
|
||||
printf("module %d (%x): gain %f, off %f, energy %d eV, dac %d\n",imod,(detectorModules+imod),(detectorModules+imod)->gain,(detectorModules+imod)->offset, ethr,dacu);
|
||||
printf("module %d (%x): gain %f, off %f, energy %d eV, dac %d\n",imod,(unsigned int)((detectorModules+imod)),(detectorModules+imod)->gain,(detectorModules+imod)->offset, ethr,dacu);
|
||||
#endif
|
||||
} else {
|
||||
dacu=ethr;
|
||||
@ -729,7 +729,7 @@ float getDACbyIndexDACU(int ind, int imod) {
|
||||
|
||||
|
||||
int initDAC(int dac_addr, int value, int imod) {
|
||||
int i;
|
||||
// int i;
|
||||
#ifdef VERBOSE
|
||||
printf("Programming dac %d with value %d\n", dac_addr, value);
|
||||
#endif
|
||||
@ -867,7 +867,7 @@ int setSettings(int i, int imod) {
|
||||
if((retval>=HIGHGAIN)&&(retval<=VERYHIGHGAIN))
|
||||
isett=retval;
|
||||
else{
|
||||
isett==UNDEFINED;
|
||||
isett=UNDEFINED;
|
||||
printf("Error:Wrong Settings Read out:%d\n",retval);
|
||||
}
|
||||
}
|
||||
@ -940,8 +940,9 @@ int getTrimbit(int imod, int ichip, int ichan) {
|
||||
if (imod<getNModBoard() && imod>=0)
|
||||
if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip)
|
||||
return (detectorChans[imod*NCHAN*NCHIP+ichip*NCHAN+ichan] & TRIM_DR);
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod){
|
||||
@ -1381,14 +1382,14 @@ int initChipWithProbes(int obe, int ow,int nprobes, int imod){
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("\n \n \n",regval);
|
||||
// printf("\n \n \n",regval);
|
||||
printf("initChip ow=%d omask=%d probes=%d\n",ow, omask,nprobes);
|
||||
#endif
|
||||
regval|=(omask<<OUTMUX_OFFSET);
|
||||
regval|=(nprobes<<PROBES_OFFSET);
|
||||
regval|=(obe<<OUTBUF_OFFSET);
|
||||
#ifdef VERBOSE
|
||||
printf("initChip : shift in will be %08x\n",regval);
|
||||
printf("initChip : shift in will be %08x\n",(unsigned int)(regval));
|
||||
#endif
|
||||
/* clearing shift in register */
|
||||
|
||||
@ -1509,7 +1510,7 @@ int initMCBregisters(int cm, int imod){
|
||||
for (im=modmi; im<modma; im++) {
|
||||
((detectorModules+im)->reg)=cm;
|
||||
#ifdef VERBOSE
|
||||
printf("imod=%d reg=%d (%x)\n",im,(detectorModules+im)->reg,(detectorModules+im));
|
||||
printf("imod=%d reg=%d (%x)\n",im,(detectorModules+im)->reg,(unsigned int)((detectorModules+im)));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1520,12 +1521,12 @@ int initModulebyNumber(sls_detector_module myMod) {
|
||||
|
||||
printf("\ninside initmoduleynumber..\n");
|
||||
|
||||
int ichip, nchip, ichan, nchan;
|
||||
int nchip,nchan;//int ichip, nchip, ichan, nchan;
|
||||
int im, modmi,modma;
|
||||
int ft, cae, ae, coe, ocoe, counts, chanreg;
|
||||
// int ft, cae, ae, coe, ocoe, counts, chanreg;
|
||||
int imod;
|
||||
int obe;
|
||||
int ow;
|
||||
// int obe;
|
||||
// int ow;
|
||||
int v[NDAC];
|
||||
|
||||
|
||||
@ -1984,7 +1985,7 @@ int testExtPulse(int imod) {
|
||||
//startStateMachine();
|
||||
startReadOut();
|
||||
usleep(100);
|
||||
val1=decode_data(fifo_read_event());
|
||||
val1=(int*)(decode_data((int*)(fifo_read_event())));
|
||||
// val1=fifo_read_event();
|
||||
//imod=0;
|
||||
//for (imod=0; imod<nModX; imod++) {
|
||||
@ -2053,9 +2054,9 @@ int testExtPulseMux(int imod, int ow) {
|
||||
|
||||
startReadOut();
|
||||
usleep(100);
|
||||
v1=fifo_read_event();
|
||||
v1=(int*)(fifo_read_event());
|
||||
if (v1)
|
||||
values=decode_data(v1);
|
||||
values=(int*)(decode_data(v1));
|
||||
else {
|
||||
printf("no data found in fifos\n");
|
||||
return 1;
|
||||
@ -2128,9 +2129,9 @@ int testDataInOutMux(int imod, int ow, int num) {
|
||||
printf("mux %d\n",ow);
|
||||
startReadOut();
|
||||
usleep(100);
|
||||
v1=fifo_read_event();
|
||||
v1=(int*)(fifo_read_event());
|
||||
if (v1)
|
||||
values=decode_data(v1);
|
||||
values=(int*)(decode_data(v1));
|
||||
else {
|
||||
printf("no data found in fifos\n");
|
||||
return 1;
|
||||
|
@ -99,7 +99,8 @@
|
||||
#define DARK_IMAGE_REG 0x81<<11
|
||||
#define GAIN_IMAGE_REG 0x82<<11
|
||||
|
||||
|
||||
//counter block memory
|
||||
#define COUNTER_MEMORY_REG 0x85<<11
|
||||
|
||||
//not used so far
|
||||
#define SPEED_REG 0x006000
|
||||
@ -236,10 +237,11 @@
|
||||
/* multi purpose register */
|
||||
#define PHASE_STEP_BIT 0x00000001
|
||||
#define PHASE_STEP_OFFSET 0
|
||||
/* #define READOUT_BUSY_BIT 0x00000002
|
||||
#define FIFOTEST_BUSY_BIT 0x00000004
|
||||
#define WAITING_FOR_TRIGGER_BIT 0x00000008
|
||||
#define DELAYBEFORE_BIT 0x00000010 */
|
||||
// #define xxx_BIT 0x00000002
|
||||
#define RESET_COUNTER_BIT 0x00000004
|
||||
#define RESET_COUNTER_OFFSET 2
|
||||
//#define xxx_BIT 0x00000008
|
||||
//#define xxx_BIT 0x00000010
|
||||
#define SW1_BIT 0x00000020
|
||||
#define SW1_OFFSET 5
|
||||
#define WRITE_BACK_BIT 0x00000040
|
||||
|
@ -94,7 +94,9 @@ int decode_function(int file_des) {
|
||||
#endif
|
||||
n = receiveDataOnly(file_des,&fnum,sizeof(fnum));
|
||||
if (n <= 0) {
|
||||
#ifdef VERBOSE
|
||||
printf("ERROR reading from socket %d, %d %d\n", n, fnum, file_des);
|
||||
#endif
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
@ -103,13 +105,13 @@ int decode_function(int file_des) {
|
||||
#endif
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf( "calling function fnum = %d %x\n",fnum,flist[fnum]);
|
||||
printf( "calling function fnum = %d %x\n",fnum,(unsigned int)(flist[fnum]));
|
||||
#endif
|
||||
if (fnum<0 || fnum>255)
|
||||
fnum=255;
|
||||
retval=(*flist[fnum])(file_des);
|
||||
if (retval==FAIL)
|
||||
printf( "Error executing the function = %d \n",fnum);
|
||||
printf( "Error executing the function = %d \n",fnum);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -163,6 +165,8 @@ int function_table() {
|
||||
flist[F_LOAD_IMAGE]=&load_image;
|
||||
flist[F_SET_MASTER]=&set_master;
|
||||
flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization;
|
||||
flist[F_READ_COUNTER_BLOCK]=&read_counter_block;
|
||||
flist[F_RESET_COUNTER_BLOCK]=&reset_counter_block;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -368,6 +372,7 @@ int get_max_number_of_modules(int file_des) {
|
||||
default:
|
||||
ret=FAIL;
|
||||
retval=FAIL;
|
||||
break;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("Max number of module in dimension %d is %d\n",arg,ret );
|
||||
@ -402,70 +407,69 @@ int get_max_number_of_modules(int file_des) {
|
||||
//index 3 is out trigger
|
||||
|
||||
int set_external_signal_flag(int file_des) {
|
||||
int n;
|
||||
int arg[2];
|
||||
int ret=OK;
|
||||
int signalindex;
|
||||
enum externalSignalFlag flag, retval;
|
||||
|
||||
sprintf(mess,"Can't set external signal flag\n");
|
||||
int n;
|
||||
int arg[2];
|
||||
int ret=OK;
|
||||
int signalindex;
|
||||
enum externalSignalFlag flag, retval;
|
||||
|
||||
/* receive arguments */
|
||||
n = receiveDataOnly(file_des,&arg,sizeof(arg));
|
||||
if (n < 0) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
retval=SIGNAL_OFF;
|
||||
if (ret==OK) {
|
||||
signalindex=arg[0];
|
||||
flag=arg[1];
|
||||
/* execute action */
|
||||
switch (flag) {
|
||||
case GET_EXTERNAL_SIGNAL_FLAG:
|
||||
retval=getExtSignal(signalindex);
|
||||
break;
|
||||
sprintf(mess,"Can't set external signal flag\n");
|
||||
|
||||
default:
|
||||
if (differentClients==0 || lockStatus==0) {
|
||||
retval=setExtSignal(signalindex,flag);
|
||||
} else {
|
||||
if (lockStatus!=0) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
||||
/* receive arguments */
|
||||
n = receiveDataOnly(file_des,&arg,sizeof(arg));
|
||||
if (n < 0) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
}
|
||||
retval=SIGNAL_OFF;
|
||||
if (ret==OK) {
|
||||
signalindex=arg[0];
|
||||
flag=arg[1];
|
||||
/* execute action */
|
||||
switch (flag) {
|
||||
case GET_EXTERNAL_SIGNAL_FLAG:
|
||||
retval=getExtSignal(signalindex);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
default:
|
||||
if (differentClients==0 || lockStatus==0) {
|
||||
retval=setExtSignal(signalindex,flag);
|
||||
} else {
|
||||
if (lockStatus!=0) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n", lastClientIP);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
printf("Setting external signal %d to flag %d\n",signalindex,flag );
|
||||
printf("Set to flag %d\n",retval);
|
||||
printf("Setting external signal %d to flag %d\n",signalindex,flag );
|
||||
printf("Set to flag %d\n",retval);
|
||||
#endif
|
||||
|
||||
} else {
|
||||
ret=FAIL;
|
||||
}
|
||||
} else {
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
if (ret==OK && differentClients!=0)
|
||||
ret=FORCE_UPDATE;
|
||||
if (ret==OK && differentClients!=0)
|
||||
ret=FORCE_UPDATE;
|
||||
|
||||
|
||||
/* send answer */
|
||||
/* send OK/failed */
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if (ret!=FAIL) {
|
||||
/* send return argument */
|
||||
n += sendDataOnly(file_des,&retval,sizeof(retval));
|
||||
} else {
|
||||
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||
}
|
||||
/* send answer */
|
||||
/* send OK/failed */
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if (ret!=FAIL) {
|
||||
/* send return argument */
|
||||
n += sendDataOnly(file_des,&retval,sizeof(retval));
|
||||
} else {
|
||||
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||
}
|
||||
|
||||
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -590,6 +594,7 @@ int get_id(int file_des) {
|
||||
printf("Required unknown id %d \n", arg);
|
||||
ret=FAIL;
|
||||
retval=FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -728,6 +733,7 @@ int digital_test(int file_des) {
|
||||
printf("Unknown digital test required %d\n",arg);
|
||||
ret=FAIL;
|
||||
retval=FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -946,6 +952,7 @@ int set_dac(int file_des) {
|
||||
printf("Unknown DAC index %d\n",ind);
|
||||
sprintf(mess,"Unknown DAC index %d\n",ind);
|
||||
ret=FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret==OK) {
|
||||
@ -1044,6 +1051,7 @@ int get_adc(int file_des) {
|
||||
printf("Unknown DAC index %d\n",ind);
|
||||
sprintf(mess,"Unknown DAC index %d\n",ind);
|
||||
ret=FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret==OK)
|
||||
@ -1354,7 +1362,7 @@ int set_module(int file_des) {
|
||||
float *myAdc=malloc(NADC*sizeof(int));
|
||||
int retval, n;
|
||||
int ret=OK;
|
||||
int dr, ow;
|
||||
int dr;// ow;
|
||||
|
||||
dr=setDynamicRange(-1);
|
||||
|
||||
@ -1905,10 +1913,6 @@ int get_run_status(int file_des) {
|
||||
|
||||
int read_frame(int file_des) {
|
||||
|
||||
#ifdef VERBOSE
|
||||
int n;
|
||||
#endif
|
||||
|
||||
if (differentClients==1 && lockStatus==1) {
|
||||
dataret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
@ -1923,7 +1927,7 @@ int read_frame(int file_des) {
|
||||
if ((dataretval=(char*)fifo_read_event())) {
|
||||
dataret=OK;
|
||||
#ifdef VERYVERBOSE
|
||||
printf("Sending ptr %x %d\n",dataretval, dataBytes);
|
||||
printf("Sending ptr %x %d\n",(unsigned int)(dataretval), dataBytes);
|
||||
#endif
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,dataretval,dataBytes);
|
||||
@ -1936,7 +1940,7 @@ int read_frame(int file_des) {
|
||||
//might add delay????
|
||||
if(getFrames()>-2) {
|
||||
dataret=FAIL;
|
||||
sprintf(mess,"no data and run stopped: %d frames left\n",getFrames()+2);
|
||||
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
|
||||
printf("%s\n",mess);
|
||||
} else {
|
||||
dataret=FINISHED;
|
||||
@ -1944,12 +1948,12 @@ int read_frame(int file_des) {
|
||||
printf("%s\n",mess);
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
printf("%d %d %x %s\n",sizeof(mess),strlen(mess), mess,mess);
|
||||
printf("%d %d %x %s\n",(int)(sizeof(mess)),(int)(strlen(mess)),(unsigned int)( mess),mess);
|
||||
#endif
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,mess,sizeof(mess));
|
||||
#ifdef VERYVERBOSE
|
||||
printf("message sent\n",mess);
|
||||
printf("message sent %s\n",mess);
|
||||
#endif
|
||||
printf("dataret %d\n",dataret);
|
||||
return dataret;
|
||||
@ -1967,14 +1971,14 @@ int read_frame(int file_des) {
|
||||
for (iframes=0; iframes<nframes; iframes++) {
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
#ifdef VERYVERBOSE
|
||||
printf("sending pointer %x of size %d\n",dataretval,dataBytes);
|
||||
printf("sending pointer %x of size %d\n",(unsigned int)(dataretval),dataBytes);
|
||||
#endif
|
||||
sendDataOnly(file_des,dataretval,dataBytes);
|
||||
dataretval+=dataBytes;
|
||||
}
|
||||
if (getFrames()>-2) {
|
||||
dataret=FAIL;
|
||||
sprintf(mess,"no data and run stopped: %d frames left\n",getFrames()+2);
|
||||
sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
|
||||
printf("%s\n",mess);
|
||||
} else {
|
||||
dataret=FINISHED;
|
||||
@ -1984,7 +1988,7 @@ int read_frame(int file_des) {
|
||||
dataret=FORCE_UPDATE;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("Frames left %d\n",getFrames());
|
||||
printf("Frames left %d\n",(int)(getFrames()));
|
||||
#endif
|
||||
sendDataOnly(file_des,&dataret,sizeof(dataret));
|
||||
sendDataOnly(file_des,mess,sizeof(mess));
|
||||
@ -2118,6 +2122,7 @@ int set_timer(int file_des) {
|
||||
default:
|
||||
ret=FAIL;
|
||||
sprintf(mess,"timer index unknown %d\n",ind);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2142,7 +2147,7 @@ int set_timer(int file_des) {
|
||||
n = sendDataOnly(file_des,mess,sizeof(mess));
|
||||
} else {
|
||||
#ifdef VERBOSE
|
||||
printf("returning ok %d\n",sizeof(retval));
|
||||
printf("returning ok %d\n",(int)(sizeof(retval)));
|
||||
#endif
|
||||
|
||||
n = sendDataOnly(file_des,&retval,sizeof(retval));
|
||||
@ -2214,6 +2219,7 @@ int get_time_left(int file_des) {
|
||||
default:
|
||||
ret=FAIL;
|
||||
sprintf(mess,"timer index unknown %d\n",ind);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2353,6 +2359,7 @@ int set_speed(int file_des) {
|
||||
break;
|
||||
default:
|
||||
ret=FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -2375,6 +2382,7 @@ int set_speed(int file_des) {
|
||||
break;
|
||||
default:
|
||||
ret=FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2448,7 +2456,8 @@ int set_readout_flags(int file_des) {
|
||||
default:
|
||||
ret=setStoreInRAM(0);
|
||||
regret=setConfigurationRegister(0);
|
||||
ret=OK;
|
||||
ret=OK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
retval=NORMAL_READOUT;
|
||||
@ -2550,6 +2559,7 @@ int execute_trimming(int file_des) {
|
||||
printf("Unknown trimming mode\n");
|
||||
sprintf(mess,"Unknown trimming mode\n");
|
||||
ret=FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2689,7 +2699,7 @@ int send_update(int file_des) {
|
||||
|
||||
int ret=OK;
|
||||
enum detectorSettings t;
|
||||
int thr, n;
|
||||
int n;//int thr, n;
|
||||
//int it;
|
||||
int64_t retval, tns=-1;
|
||||
n = sendDataOnly(file_des,lastClientIP,sizeof(lastClientIP));
|
||||
@ -2766,10 +2776,10 @@ int configure_mac(int file_des) {
|
||||
printf("destination ip is %d.%d.%d.%d = 0x%x \n",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff,ipad);
|
||||
printf("macad:%llx\n",imacadd);
|
||||
for (i=0;i<6;i++)
|
||||
printf("mac adress %d is 0x%x \n",6-i,((imacadd>>(8*i))&0xFF));
|
||||
printf("mac adress %d is 0x%x \n",6-i,(unsigned int)(((imacadd>>(8*i))&0xFF)));
|
||||
printf("server macad:%llx\n",iservermacadd);
|
||||
for (i=0;i<6;i++)
|
||||
printf("server mac adress %d is 0x%x \n",6-i,((iservermacadd>>(8*i))&0xFF));
|
||||
printf("server mac adress %d is 0x%x \n",6-i,(unsigned int)(((iservermacadd>>(8*i))&0xFF)));
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
@ -2819,10 +2829,10 @@ int load_image(int file_des) {
|
||||
int retval;
|
||||
int ret=OK;
|
||||
int n;
|
||||
int index;
|
||||
short int ImageVals[1280];
|
||||
enum imageType index;
|
||||
short int ImageVals[NCHAN*NCHIP];
|
||||
|
||||
sprintf(mess,"Can't load image\n");
|
||||
sprintf(mess,"Loading image failed\n");
|
||||
|
||||
n = receiveDataOnly(file_des,&index,sizeof(index));
|
||||
if (n < 0) {
|
||||
@ -2830,7 +2840,7 @@ int load_image(int file_des) {
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
n = receiveDataOnly(file_des,ImageVals,sizeof(ImageVals));
|
||||
n = receiveDataOnly(file_des,ImageVals,dataBytes);
|
||||
if (n < 0) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
@ -2839,22 +2849,21 @@ int load_image(int file_des) {
|
||||
switch (index) {
|
||||
case DARK_IMAGE :
|
||||
#ifdef VERBOSE
|
||||
printf(" Loading Dark image\n");
|
||||
printf("Loading Dark image\n");
|
||||
#endif
|
||||
break;
|
||||
case GAIN_IMAGE :
|
||||
#ifdef VERBOSE
|
||||
printf(" Loading Gain image\n");
|
||||
printf("Loading Gain image\n");
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
printf("Unknown index %d\n",index);
|
||||
sprintf(mess,"Unknown index %d\n",index);
|
||||
ret=FAIL;
|
||||
break;
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
printf("%d\n%d\n",ImageVals[0],ImageVals[1]);
|
||||
#endif
|
||||
|
||||
if (ret==OK) {
|
||||
if (differentClients==1 && lockStatus==1) {
|
||||
ret=FAIL;
|
||||
@ -2866,9 +2875,7 @@ int load_image(int file_des) {
|
||||
}
|
||||
}
|
||||
|
||||
if(ret==FAIL)
|
||||
printf("Loading image failed\n");
|
||||
else{
|
||||
if(ret==OK){
|
||||
if (differentClients)
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
@ -2979,3 +2986,98 @@ int set_synchronization(int file_des) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int read_counter_block(int file_des) {
|
||||
|
||||
int ret=OK;
|
||||
int n;
|
||||
int startACQ;
|
||||
//char *retval=NULL;
|
||||
short int CounterVals[NCHAN*NCHIP];
|
||||
|
||||
sprintf(mess,"Read counter block failed\n");
|
||||
|
||||
n = receiveDataOnly(file_des,&startACQ,sizeof(startACQ));
|
||||
if (n < 0) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
if (ret==OK) {
|
||||
if (differentClients==1 && lockStatus==1) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
} else{
|
||||
ret=readCounterBlock(startACQ,CounterVals);
|
||||
#ifdef VERBOSE
|
||||
int i;
|
||||
for(i=0;i<6;i++)
|
||||
printf("%d:%d\t",i,CounterVals[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if(ret!=FAIL){
|
||||
if (differentClients)
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
/* send answer */
|
||||
/* send OK/failed */
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if (ret!=FAIL) {
|
||||
/* send return argument */
|
||||
n += sendDataOnly(file_des,CounterVals,dataBytes);//1280*2
|
||||
} else {
|
||||
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||
}
|
||||
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int reset_counter_block(int file_des) {
|
||||
|
||||
int ret=OK;
|
||||
int n;
|
||||
int startACQ;
|
||||
|
||||
sprintf(mess,"Reset counter block failed\n");
|
||||
|
||||
n = receiveDataOnly(file_des,&startACQ,sizeof(startACQ));
|
||||
if (n < 0) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
ret=FAIL;
|
||||
}
|
||||
|
||||
if (ret==OK) {
|
||||
if (differentClients==1 && lockStatus==1) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
} else
|
||||
ret=resetCounterBlock(startACQ);
|
||||
}
|
||||
|
||||
if(ret==OK){
|
||||
if (differentClients)
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
/* send answer */
|
||||
/* send OK/failed */
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if (ret==FAIL)
|
||||
n += sendDataOnly(file_des,mess,sizeof(mess));
|
||||
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -78,5 +78,7 @@ int send_update(int);
|
||||
int configure_mac(int);
|
||||
|
||||
int load_image(int);
|
||||
int read_counter_block(int);
|
||||
int reset_counter_block(int);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user