mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-29 01:20:02 +02:00
created programming mode, where only programming is allowed, one has to restart servers afterwards
This commit is contained in:
parent
a37bbc50fe
commit
68e9648854
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define GOODBYE (-200)
|
#define GOODBYE (-200)
|
||||||
|
#define PROGRAMMING_MODE (-200)
|
||||||
#define MIN_REQRD_VRSN_T_RD_API 0x171220
|
#define MIN_REQRD_VRSN_T_RD_API 0x171220
|
||||||
#define REQRD_FRMWR_VRSN 0x180226
|
#define REQRD_FRMWR_VRSN 0x180226
|
||||||
|
|
||||||
|
@ -7834,6 +7834,7 @@ int slsDetector::programFPGA(string fname){
|
|||||||
updateDetector();
|
updateDetector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//remapping stop server
|
//remapping stop server
|
||||||
fnum=F_RESET_FPGA;
|
fnum=F_RESET_FPGA;
|
||||||
int stopret;
|
int stopret;
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
/* global variables */
|
/* global variables */
|
||||||
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
|
#define CTRL_SRVR_INIT_TIME_US (300 * 1000)
|
||||||
int gpioDefined=0;
|
int gpioDefined=0;
|
||||||
char mtdvalue[10];
|
#define MTDSIZE 10
|
||||||
|
char mtdvalue[MTDSIZE];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -85,9 +86,12 @@ int startWritingFPGAprogram(FILE** filefp){
|
|||||||
|
|
||||||
//getting the drive
|
//getting the drive
|
||||||
char output[255];
|
char output[255];
|
||||||
|
memset(output, 0, 255);
|
||||||
FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r");
|
FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r");
|
||||||
fgets(output, sizeof(output), fp);
|
fgets(output, sizeof(output), fp);
|
||||||
pclose(fp);
|
pclose(fp);
|
||||||
|
//cprintf(RED,"output: %s\n", output);
|
||||||
|
memset(mtdvalue, 0, MTDSIZE);
|
||||||
strcpy(mtdvalue,"/dev/");
|
strcpy(mtdvalue,"/dev/");
|
||||||
char* pch = strtok(output,":");
|
char* pch = strtok(output,":");
|
||||||
if(pch == NULL){
|
if(pch == NULL){
|
||||||
@ -161,12 +165,12 @@ int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp){
|
|||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("\nWriting of FPGA Program\n");
|
printf("\nWriting of FPGA Program\n");
|
||||||
cprintf(BLUE,"address of fpgasrc:%p\n",(void *)fpgasrc);
|
cprintf(BLUE,"address of fpgasrc:%p\n",(void *)fpgasrc);
|
||||||
cprintf(BLUE,"fsize:%d\n",fsize);
|
cprintf(BLUE,"fsize:%lu\n",fsize);
|
||||||
cprintf(BLUE,"pointer:%p\n",(void*)filefp);
|
cprintf(BLUE,"pointer:%p\n",(void*)filefp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){
|
if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){
|
||||||
cprintf(RED,"Could not write FPGA source to flash\n");
|
cprintf(RED,"Could not write FPGA source to flash (size:%lu)\n", fsize);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
|
@ -24,51 +24,69 @@ int main(int argc, char *argv[]){
|
|||||||
int retval=OK;
|
int retval=OK;
|
||||||
int sd, fd;
|
int sd, fd;
|
||||||
int debugflag = 0;
|
int debugflag = 0;
|
||||||
|
int controlserver = 1;
|
||||||
|
|
||||||
// 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
|
// circumvent the basic tests
|
||||||
if(argc > 1) {
|
{
|
||||||
if(!strcasecmp(argv[1],"-debug")){
|
int i;
|
||||||
debugflag = 1;
|
for (i = 1; i < argc; ++i) {
|
||||||
argc=1;
|
if(!strcasecmp(argv[i],"-stopserver")) {
|
||||||
}
|
cprintf(BLUE,"detected stop server\n");
|
||||||
}
|
controlserver = 0;
|
||||||
|
}
|
||||||
|
else if(!strcasecmp(argv[i],"-debug")){
|
||||||
|
cprintf(BLUE,"detected debug mode\n");
|
||||||
|
debugflag = 1;
|
||||||
|
}
|
||||||
|
#ifdef JUNGFRAUD
|
||||||
|
else if(!strcasecmp(argv[i],"-programming")){
|
||||||
|
cprintf(BLUE,"detected programming mode\n");
|
||||||
|
debugflag = PROGRAMMING_MODE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else if(strchr(argv[i],'-') != NULL) {
|
||||||
|
cprintf(RED,"cannot scan program argument %s\n", argv[1]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef STOP_SERVER
|
#ifdef STOP_SERVER
|
||||||
char cmd[100];
|
char cmd[100];
|
||||||
|
memset(cmd, 0, 100);
|
||||||
#endif
|
#endif
|
||||||
if (argc==1) {
|
if (controlserver) {
|
||||||
portno = DEFAULT_PORTNO;
|
portno = DEFAULT_PORTNO;
|
||||||
cprintf(BLUE,
|
cprintf(BLUE,
|
||||||
"********************************************************\n"
|
"********************************************************\n"
|
||||||
"********* opening control server on port %d **********\n"
|
"********* opening control server on port %d **********\n"
|
||||||
"********************************************************\n\n"
|
"********************************************************\n\n"
|
||||||
, portno);
|
, portno);
|
||||||
b=1;
|
|
||||||
basictests(debugflag);
|
|
||||||
#ifdef STOP_SERVER
|
#ifdef STOP_SERVER
|
||||||
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
|
{
|
||||||
//cprintf(BLUE,"cmd:%s\n", cmd);
|
int i;
|
||||||
system(cmd);
|
for (i = 0; i < argc; ++i)
|
||||||
|
sprintf(cmd, "%s %s", cmd, argv[i]);
|
||||||
|
sprintf(cmd,"%s -stopserver&", cmd);
|
||||||
|
cprintf(BLUE,"cmd:%s\n", cmd);
|
||||||
|
system(cmd);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
portno = DEFAULT_PORTNO+1;
|
portno = DEFAULT_PORTNO+1;
|
||||||
if ( sscanf(argv[1],"%d",&portno) == 0) {
|
|
||||||
printf("could not open stop server: unknown port\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
cprintf(BLUE,
|
cprintf(BLUE,
|
||||||
"********************************************************\n"
|
"********************************************************\n"
|
||||||
"*********** opening stop server on port %d ***********\n"
|
"*********** opening stop server on port %d ***********\n"
|
||||||
"********************************************************\n\n"
|
"********************************************************\n\n"
|
||||||
, portno);
|
, portno);
|
||||||
b=0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init_detector(b); //defined in slsDetectorServer_funcs
|
setModeFlag(debugflag); //defined in slsDetectorServer_funcs
|
||||||
|
init_detector(controlserver); //defined in slsDetectorServer_funcs
|
||||||
|
|
||||||
sd=bindSocket(portno); //defined in communication_funcs
|
sd=bindSocket(portno); //defined in communication_funcs
|
||||||
sockfd=sd;
|
sockfd=sd;
|
||||||
|
@ -52,8 +52,11 @@ int printSocketReadError() {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void basictests(int flag) {
|
void setModeFlag(int flag) {
|
||||||
debugflag = flag;
|
debugflag = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void basictests() {
|
||||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||||
checkFirmwareCompatibility(debugflag);
|
checkFirmwareCompatibility(debugflag);
|
||||||
#endif
|
#endif
|
||||||
@ -68,6 +71,10 @@ void init_detector(int controlserver) {
|
|||||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||||
if (controlserver) {
|
if (controlserver) {
|
||||||
isControlServer = 1;
|
isControlServer = 1;
|
||||||
|
basictests();
|
||||||
|
#ifdef JUNGFRAUD
|
||||||
|
if (debugflag != PROGRAMMING_MODE)
|
||||||
|
#endif
|
||||||
initControlServer();
|
initControlServer();
|
||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
dhcpipad = getDetectorIP();
|
dhcpipad = getDetectorIP();
|
||||||
@ -102,6 +109,14 @@ int decode_function(int file_des) {
|
|||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf(" calling function fnum=%d, (%s) located at 0x%x\n", fnum, getFunctionName((enum detFuncs)fnum), (unsigned int)flist[fnum]);
|
printf(" calling function fnum=%d, (%s) located at 0x%x\n", fnum, getFunctionName((enum detFuncs)fnum), (unsigned int)flist[fnum]);
|
||||||
|
#endif
|
||||||
|
#ifdef JUNGFRAUD
|
||||||
|
if ((debugflag == PROGRAMMING_MODE) &&
|
||||||
|
((fnum != F_PROGRAM_FPGA) && (fnum != F_GET_DETECTOR_TYPE) &&
|
||||||
|
(fnum != F_RESET_FPGA) && (fnum != F_UPDATE_CLIENT))) {
|
||||||
|
sprintf(mess,"This Function %s cannot be executed. ", getFunctionName((enum detFuncs)fnum));
|
||||||
|
ret=(M_nofuncMode)(file_des);
|
||||||
|
} else
|
||||||
#endif
|
#endif
|
||||||
if (fnum<0 || fnum>=NUM_DET_FUNCTIONS) {
|
if (fnum<0 || fnum>=NUM_DET_FUNCTIONS) {
|
||||||
cprintf(BG_RED,"Unknown function enum %d\n", fnum);
|
cprintf(BG_RED,"Unknown function enum %d\n", fnum);
|
||||||
@ -315,6 +330,21 @@ int M_nofunc(int file_des){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int M_nofuncMode(int file_des){
|
||||||
|
int ret=FAIL,ret1=FAIL;
|
||||||
|
int n=0;
|
||||||
|
//to receive any arguments
|
||||||
|
while (n > 0)
|
||||||
|
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
|
||||||
|
|
||||||
|
strcat(mess, "On-board detector server in programming mode. Restart detector server in normal mode (without any arguments).\n");
|
||||||
|
cprintf(BG_RED,"Error: %s",mess);
|
||||||
|
n = sendData(file_des,&ret1,sizeof(ret1),INT32);
|
||||||
|
n = sendData(file_des,mess,sizeof(mess),OTHER); // mess is defined at function call
|
||||||
|
|
||||||
|
// return ok / fail
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -4924,7 +4954,7 @@ int program_fpga(int file_des) {
|
|||||||
int ret=OK,ret1=OK;
|
int ret=OK,ret1=OK;
|
||||||
int n=0;
|
int n=0;
|
||||||
sprintf(mess,"program FPGA failed\n");
|
sprintf(mess,"program FPGA failed\n");
|
||||||
|
printf("Programming FPGA...")
|
||||||
|
|
||||||
#ifndef JUNGFRAUD
|
#ifndef JUNGFRAUD
|
||||||
//to receive any arguments
|
//to receive any arguments
|
||||||
@ -4987,10 +5017,10 @@ int program_fpga(int file_des) {
|
|||||||
unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb
|
unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb
|
||||||
if(unitprogramsize > filesize) //less than 2mb
|
if(unitprogramsize > filesize) //less than 2mb
|
||||||
unitprogramsize = filesize;
|
unitprogramsize = filesize;
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("unit size to receive is:%d\n",unitprogramsize);
|
printf("unit size to receive is:%d\n",unitprogramsize);
|
||||||
printf("filesize:%d currentpointer:%d\n",filesize,currentPointer);
|
printf("filesize:%d currentpointer:%d\n",filesize,currentPointer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//receive
|
//receive
|
||||||
n = receiveData(file_des,fpgasrc,unitprogramsize,OTHER);
|
n = receiveData(file_des,fpgasrc,unitprogramsize,OTHER);
|
||||||
@ -5035,15 +5065,16 @@ int program_fpga(int file_des) {
|
|||||||
if(fp!=NULL)
|
if(fp!=NULL)
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("Done with program receiving command\n");
|
printf("Done with program receiving command\n");
|
||||||
#endif
|
#endif
|
||||||
if (isControlServer)
|
|
||||||
basictests(debugflag);
|
if (isControlServer)
|
||||||
init_detector(isControlServer);
|
basictests(debugflag);
|
||||||
|
init_detector(isControlServer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ret==OK)
|
if (ret==OK)
|
||||||
ret=FORCE_UPDATE;
|
ret=FORCE_UPDATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ret could be swapped during sendData
|
// ret could be swapped during sendData
|
||||||
@ -5085,9 +5116,13 @@ int reset_fpga(int file_des) {
|
|||||||
}
|
}
|
||||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||||
else {
|
else {
|
||||||
if (isControlServer)
|
if (isControlServer) {
|
||||||
basictests(debugflag);
|
basictests(debugflag);
|
||||||
initControlServer(isControlServer);
|
#ifdef JUNGFRAUD
|
||||||
|
if (debugflag != PROGRAMMING_MODE)
|
||||||
|
#endif
|
||||||
|
initControlServer();
|
||||||
|
}
|
||||||
ret = FORCE_UPDATE;
|
ret = FORCE_UPDATE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,12 +6,14 @@
|
|||||||
|
|
||||||
// initialization functions
|
// initialization functions
|
||||||
int printSocketReadError();
|
int printSocketReadError();
|
||||||
void basictests(int);
|
void setModeFlag(int);
|
||||||
|
void basictests();
|
||||||
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);
|
||||||
void function_table();
|
void function_table();
|
||||||
int M_nofunc(int);
|
int M_nofunc(int);
|
||||||
|
int M_nofuncMode(int);
|
||||||
|
|
||||||
// functions called by client
|
// functions called by client
|
||||||
int exec_command(int);
|
int exec_command(int);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user