jungfrau with the option to start in debug mode to bypass the checks and tests

This commit is contained in:
Dhanya Maliakal 2017-09-20 16:20:39 +02:00
parent 092487c08e
commit 862169e178
7 changed files with 27 additions and 10 deletions

View File

@ -25,11 +25,17 @@ int32_t clkPhase[2] = {0, 0};
/* basic tests */ /* basic tests */
void checkFirmwareCompatibility() { void checkFirmwareCompatibility(int flag) {
defineGPIOpins(); defineGPIOpins();
resetFPGA(); resetFPGA();
if ((mapCSP0() == FAIL) || (checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL)) { if (mapCSP0() == FAIL) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
exit(EXIT_FAILURE);
}
// does check only if flag is 0 (by default), set by command line
if ((!flag) && ((checkType() == FAIL) || (testFpga() == FAIL) || (testBus() == FAIL))) {
cprintf(BG_RED, "Dangerous to continue. Goodbye!\n"); cprintf(BG_RED, "Dangerous to continue. Goodbye!\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

View File

@ -17,7 +17,7 @@ Here are the definitions, but the actual implementation should be done for each
// basic tests // basic tests
void checkFirmwareCompatibility(); void checkFirmwareCompatibility(int flag);
#ifdef JUNGFRAUD #ifdef JUNGFRAUD
int checkType(); int checkType();
u_int32_t testFpga(void); u_int32_t testFpga(void);

View File

@ -23,11 +23,20 @@ int main(int argc, char *argv[]){
int portno, b; int portno, b;
int retval=OK; int retval=OK;
int sd, fd; int sd, fd;
int debugflag = 0;
// if socket crash, ignores SISPIPE, prevents global signal handler // if socket crash, ignores SISPIPE, prevents global signal handler
// subsequent read/write to socket gives error - must handle locally // subsequent read/write to socket gives error - must handle locally
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
// circumvent the basic tests
if(argc > 1) {
if(!strcasecmp(argv[1],"-debug")){
debugflag = 1;
argc=1;
}
}
#ifdef STOP_SERVER #ifdef STOP_SERVER
char cmd[100]; char cmd[100];
@ -40,9 +49,10 @@ int main(int argc, char *argv[]){
"********************************************************\n\n" "********************************************************\n\n"
, portno); , portno);
b=1; b=1;
basictests(); basictests(debugflag);
#ifdef STOP_SERVER #ifdef STOP_SERVER
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1); sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
//cprintf(BLUE,"cmd:%s\n", cmd);
system(cmd); system(cmd);
#endif #endif
} else { } else {

View File

@ -38,7 +38,7 @@ int (*flist[NUM_DET_FUNCTIONS])(int);
char mess[MAX_STR_LENGTH]; char mess[MAX_STR_LENGTH];
int dataBytes = 10; int dataBytes = 10;
int isControlServer = 0; int isControlServer = 0;
int debugflag = 0;
/* initialization functions */ /* initialization functions */
@ -47,9 +47,10 @@ int printSocketReadError() {
return FAIL; return FAIL;
} }
void basictests() { void basictests(int flag) {
debugflag = flag;
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
checkFirmwareCompatibility(); checkFirmwareCompatibility(debugflag);
#endif #endif
} }
@ -4605,7 +4606,7 @@ int program_fpga(int file_des) {
printf("Done with program receiving command\n"); printf("Done with program receiving command\n");
#endif #endif
if (isControlServer) if (isControlServer)
basictests(); basictests(debugflag);
init_detector(isControlServer); init_detector(isControlServer);
} }
#endif #endif
@ -4653,7 +4654,7 @@ int reset_fpga(int file_des) {
#ifdef SLS_DETECTOR_FUNCTION_LIST #ifdef SLS_DETECTOR_FUNCTION_LIST
else { else {
if (isControlServer) if (isControlServer)
basictests(); basictests(debugflag);
init_detector(isControlServer); init_detector(isControlServer);
ret = FORCE_UPDATE; ret = FORCE_UPDATE;
} }

View File

@ -6,7 +6,7 @@
// initialization functions // initialization functions
int printSocketReadError(); int printSocketReadError();
void basictests(); void basictests(int);
void init_detector(int); void init_detector(int);
int decode_function(int); int decode_function(int);
const char* getFunctionName(enum detFuncs func); const char* getFunctionName(enum detFuncs func);