mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 00:07:13 +02:00
configuremac after starting receiver, also telling the server to send packets to receiver or cpu with receiver start and receiver stop
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@290 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -705,6 +705,33 @@ int setContinousReadOut(int d) {
|
||||
}
|
||||
|
||||
|
||||
int startReceiver(int start) {
|
||||
u_int32_t addr=CONFIG_REG;
|
||||
#ifdef VERBOSE
|
||||
if(start)
|
||||
printf("Setting up detector to send to Receiver\n");
|
||||
else
|
||||
printf("Setting up detector to send to CPU\n");
|
||||
#endif
|
||||
int reg=bus_r(addr);
|
||||
//for start recever, write 0 and for stop, write 1
|
||||
if (!start)
|
||||
bus_w(CONFIG_REG,reg|CPU_OR_RECEIVER_BIT);
|
||||
else
|
||||
bus_w(CONFIG_REG,reg&(~CPU_OR_RECEIVER_BIT));
|
||||
|
||||
reg=bus_r(addr);
|
||||
#ifdef VERBOSE
|
||||
printf("Config Reg %x\n", reg);
|
||||
#endif
|
||||
if (start && (!(reg&CPU_OR_RECEIVER_BIT)))
|
||||
return OK;
|
||||
if(!start && (reg&CPU_OR_RECEIVER_BIT))
|
||||
return OK;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
u_int64_t getDetectorNumber() {
|
||||
char output[255],mac[255]="";
|
||||
u_int64_t res=0;
|
||||
|
@ -53,6 +53,7 @@ int setTiming(int t);
|
||||
int setConfigurationRegister(int d);
|
||||
int setToT(int d);
|
||||
int setContinousReadOut(int d);
|
||||
int startReceiver(int d);
|
||||
|
||||
int setDACRegister(int idac, int val, int imod);
|
||||
|
||||
|
@ -181,7 +181,8 @@
|
||||
/* for config register *///not really used yet
|
||||
#define TOT_ENABLE_BIT 0x00000002
|
||||
#define TIMED_GATE_BIT 0x00000004
|
||||
#define CONT_RO_ENABLE_BIT 0x00080000
|
||||
#define CONT_RO_ENABLE_BIT 0x00080000
|
||||
#define CPU_OR_RECEIVER_BIT 0x00001000
|
||||
|
||||
|
||||
|
||||
|
@ -175,6 +175,8 @@ int function_table() {
|
||||
flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization;
|
||||
flist[F_READ_COUNTER_BLOCK]=&read_counter_block;
|
||||
flist[F_RESET_COUNTER_BLOCK]=&reset_counter_block;
|
||||
flist[F_START_RECEIVER]=&start_receiver;
|
||||
flist[F_STOP_RECEIVER]=&stop_receiver;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -2788,18 +2790,19 @@ int configure_mac(int file_des) {
|
||||
if (imod<0)
|
||||
imod=ALLMOD;
|
||||
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
printf("Configuring MAC of module %d\n", imod);
|
||||
#endif
|
||||
//#endif
|
||||
#ifdef MCB_FUNCS
|
||||
if (ret==OK) {
|
||||
retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit);
|
||||
if(retval==-1) ret=FAIL;
|
||||
if(retval==-1)
|
||||
ret=FAIL;
|
||||
}
|
||||
#endif
|
||||
#ifdef VERBOSE
|
||||
//#ifdef VERBOSE
|
||||
printf("Configured MAC with retval %d\n", retval);
|
||||
#endif
|
||||
//#endif
|
||||
if (ret==FAIL) {
|
||||
printf("configuring MAC of mod %d failed\n", imod);
|
||||
}
|
||||
@ -3081,3 +3084,72 @@ int reset_counter_block(int file_des) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int start_receiver(int file_des) {
|
||||
int ret=OK;
|
||||
int n=0;
|
||||
strcpy(mess,"Could not start receiver\n");
|
||||
|
||||
/* execute action if the arguments correctly arrived*/
|
||||
#ifdef MCB_FUNCS
|
||||
if (lockStatus==1 && differentClients==1){//necessary???
|
||||
sprintf(mess,"Receiver locked by %s\n", lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
else
|
||||
ret = startReceiver(1);
|
||||
#endif
|
||||
|
||||
|
||||
if(ret==OK && differentClients){
|
||||
printf("Force update\n");
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
/* send answer */
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if(ret==FAIL)
|
||||
n = sendDataOnly(file_des,mess,sizeof(mess));
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int stop_receiver(int file_des) {
|
||||
int ret=OK;
|
||||
int n=0;
|
||||
|
||||
strcpy(mess,"Could not stop receiver\n");
|
||||
|
||||
/* execute action if the arguments correctly arrived*/
|
||||
#ifdef MCB_FUNCS
|
||||
if (lockStatus==1 && differentClients==1){//necessary???
|
||||
sprintf(mess,"Receiver locked by %s\n", lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
else
|
||||
ret=startReceiver(0);
|
||||
#endif
|
||||
|
||||
|
||||
if(ret==OK && differentClients){
|
||||
printf("Force update\n");
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
/* send answer */
|
||||
n = sendDataOnly(file_des,&ret,sizeof(ret));
|
||||
if(ret==FAIL)
|
||||
n = sendDataOnly(file_des,mess,sizeof(mess));
|
||||
/*return ok/fail*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -81,4 +81,7 @@ int load_image(int);
|
||||
int read_counter_block(int);
|
||||
int reset_counter_block(int);
|
||||
|
||||
int start_receiver(int);
|
||||
int stop_receiver(int);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user