mannnnyyyy changes to jungfrau serverin structure, also to eiger structure a bit

This commit is contained in:
Dhanya Maliakal
2017-05-26 18:14:44 +02:00
parent 046ac97a9b
commit f74710998d
29 changed files with 2409 additions and 1181 deletions

View File

@ -83,6 +83,191 @@ int normal = 0;
#define ONE_GIGA_BUFFER_SIZE 1040
void checkFirmwareCompatibility(){
int64_t fwversion = getDetectorId(DETECTOR_FIRMWARE_VERSION);
int64_t swversion = getDetectorId(DETECTOR_SOFTWARE_VERSION);
int64_t sw_fw_apiversion = getDetectorId(SOFTWARE_FIRMWARE_API_VERSION);
cprintf(BLUE,"\n\n********************************************************\n"
"**********************EIGER Server**********************\n"
"********************************************************\n");
cprintf(BLUE,"\n"
"Firmware Version:\t\t %lld\n"
"Software Version:\t\t %llx\n"
"F/w-S/w API Version:\t\t %lld\n"
"Required Firmware Version:\t %d\n"
"\n********************************************************\n",
fwversion,swversion,sw_fw_apiversion,REQUIRED_FIRMWARE_VERSION);
//cant read versions
if(!fwversion || !sw_fw_apiversion){
cprintf(RED,"FATAL ERROR: Cant read versions from FPGA. Please update firmware\n");
cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(-1);
}
//check for API compatibility - old server
if(sw_fw_apiversion > REQUIRED_FIRMWARE_VERSION){
cprintf(RED,"FATAL ERROR: This software version is incompatible.\n"
"Please update it to be compatible with this firmware\n\n");
cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(-1);
}
//check for firmware compatibility - old firmware
if( REQUIRED_FIRMWARE_VERSION > fwversion){
cprintf(RED,"FATAL ERROR: This firmware version is incompatible.\n"
"Please update it to v%d to be compatible with this server\n\n", REQUIRED_FIRMWARE_VERSION);
cprintf(RED,"Exiting Server. Goodbye!\n\n");
exit(-1);
}
}
int moduleTest( enum digitalTestMode arg, int imod){
//template testShiftIn from mcb_funcs.c
//CHIP_TEST
//testShiftIn
//testShiftOut
//testShiftStSel
//testDataInOutMux
//testExtPulseMux
//testOutMux
//testFpgaMux
return OK;
}
int detectorTest( enum digitalTestMode arg){
//templates from firmware_funcs.c
//DETECTOR_FIRMWARE_TEST:testFpga()
//DETECTOR_MEMORY_TEST:testRAM()
//DETECTOR_BUS_TEST:testBus()
//DETECTOR_SOFTWARE_TEST:testFpga()
return OK;
}
int64_t getDetectorId(enum idMode arg){
int64_t retval = -1;
switch(arg){
case DETECTOR_SERIAL_NUMBER:
retval = getDetectorNumber();/** to be implemented with mac? */
break;
case DETECTOR_FIRMWARE_VERSION:
return (int64_t)getFirmwareVersion();
case SOFTWARE_FIRMWARE_API_VERSION:
return (int64_t)Beb_GetFirmwareSoftwareAPIVersion();
case DETECTOR_SOFTWARE_VERSION:
retval= SVNREV;
retval= (retval <<32) | SVNDATE;
//cprintf(BLUE,"git date:%x, git rev:%x\n",SVNDATE,SVNREV);
break;
default:
break;
}
return retval;
}
u_int64_t getFirmwareVersion() {
return Beb_GetFirmwareRevision();
}
int64_t getModuleId(enum idMode arg, int imod){
/**/
return -1;
}
int getDetectorNumber(){
int res=0;
//execute and get address
char output[255];
FILE* sysFile = popen("more /home/root/executables/detid.txt", "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
sscanf(output,"%d",&res);
printf("detector id: %d\n",res);
/*
int res=0;
char hostname[100];
if (gethostname(hostname, sizeof hostname) == 0)
puts(hostname);
else
perror("gethostname");
sscanf(hostname,"%x",&res);
*/
return res;
}
u_int64_t getDetectorMAC() {
char mac[255]="";
u_int64_t res=0;
//execute and get address
char output[255];
FILE* sysFile = popen("more /sys/class/net/eth0/address", "r");
//FILE* sysFile = popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
//getting rid of ":"
char * pch;
pch = strtok (output,":");
while (pch != NULL){
strcat(mac,pch);
pch = strtok (NULL, ":");
}
sscanf(mac,"%llx",&res);
//increment by 1 for 10g
if(send_to_ten_gig)
res++;
//printf("mac:%llx\n",res);
return res;
}
int getDetectorIP(){
char temp[50]="";
int res=0;
//execute and get address
char output[255];
FILE* sysFile = popen("ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2", "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
//converting IPaddress to hex.
char* pcword = strtok (output,".");
while (pcword != NULL) {
sprintf(output,"%02x",atoi(pcword));
strcat(temp,output);
pcword = strtok (NULL, ".");
}
strcpy(output,temp);
sscanf(output, "%x", &res);
//printf("ip:%x\n",res);
return res;
}
int initDetector(){
int imod,i,n;
n = getNModBoard(1);
@ -216,148 +401,10 @@ int getNModBoard(enum dimension arg){
int64_t getModuleId(enum idMode arg, int imod){
/**/
return -1;
}
int64_t getDetectorId(enum idMode arg){
int64_t retval = -1;
switch(arg){
case DETECTOR_SERIAL_NUMBER:
retval = getDetectorNumber();/** to be implemented with mac? */
break;
case DETECTOR_FIRMWARE_VERSION:
return (int64_t)Beb_GetFirmwareRevision();
case SOFTWARE_FIRMWARE_API_VERSION:
return (int64_t)Beb_GetFirmwareSoftwareAPIVersion();
case DETECTOR_SOFTWARE_VERSION:
retval= SVNREV;
retval= (retval <<32) | SVNDATE;
//cprintf(BLUE,"git date:%x, git rev:%x\n",SVNDATE,SVNREV);
break;
default:
break;
}
return retval;
}
int getDetectorNumber(){
int res=0;
//execute and get address
char output[255];
FILE* sysFile = popen("more /home/root/executables/detid.txt", "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
sscanf(output,"%d",&res);
printf("detector id: %d\n",res);
/*
int res=0;
char hostname[100];
if (gethostname(hostname, sizeof hostname) == 0)
puts(hostname);
else
perror("gethostname");
sscanf(hostname,"%x",&res);
*/
return res;
}
u_int64_t getDetectorMAC() {
char mac[255]="";
u_int64_t res=0;
//execute and get address
char output[255];
FILE* sysFile = popen("more /sys/class/net/eth0/address", "r");
//FILE* sysFile = popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
//getting rid of ":"
char * pch;
pch = strtok (output,":");
while (pch != NULL){
strcat(mac,pch);
pch = strtok (NULL, ":");
}
sscanf(mac,"%llx",&res);
//increment by 1 for 10g
if(send_to_ten_gig)
res++;
//printf("mac:%llx\n",res);
return res;
}
int getDetectorIP(){
char temp[50]="";
int res=0;
//execute and get address
char output[255];
FILE* sysFile = popen("ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2", "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
//converting IPaddress to hex.
char* pcword = strtok (output,".");
while (pcword != NULL) {
sprintf(output,"%02x",atoi(pcword));
strcat(temp,output);
pcword = strtok (NULL, ".");
}
strcpy(output,temp);
sscanf(output, "%x", &res);
//printf("ip:%x\n",res);
return res;
}
int moduleTest( enum digitalTestMode arg, int imod){
//template testShiftIn from mcb_funcs.c
//CHIP_TEST
//testShiftIn
//testShiftOut
//testShiftStSel
//testDataInOutMux
//testExtPulseMux
//testOutMux
//testFpgaMux
return OK;
}
int detectorTest( enum digitalTestMode arg){
//templates from firmware_funcs.c
//DETECTOR_FIRMWARE_TEST:testFpga()
//DETECTOR_MEMORY_TEST:testRAM()
//DETECTOR_BUS_TEST:testBus()
//DETECTOR_SOFTWARE_TEST:testFpga()
return OK;
}