detector ip for eiger is replaced by hardware ip for 1g

This commit is contained in:
Dhanya Maliakal 2015-11-06 11:10:51 +01:00
parent bc6dfca552
commit 816543f358
4 changed files with 48 additions and 10 deletions

View File

@ -154,8 +154,9 @@ int initDetector(){
Feb_Control_SetTestModeVariable(0); Feb_Control_SetTestModeVariable(0);
Feb_Control_CheckSetup(); Feb_Control_CheckSetup();
//print detector mac //print detector mac and ip
getDetectorMAC(); printf("mac read from detector: %llx\n",getDetectorMAC());
printf("ip read from detector: %x\n",getDetectorIP());
printf("\n"); printf("\n");
return 1; return 1;
@ -283,6 +284,33 @@ u_int64_t getDetectorMAC() {
return 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){ int moduleTest( enum digitalTestMode arg, int imod){
//template testShiftIn from mcb_funcs.c //template testShiftIn from mcb_funcs.c
@ -855,13 +883,22 @@ int executeTrimming(enum trimMode mode, int par1, int par2, int imod){
int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport, int udpport2, int ival){ int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int udpport, int udpport2, int ival){
//only for 1Gbe //only for 1Gbe
if((!send_to_ten_gig) && (detectormacadd != getDetectorMAC())){ if(!send_to_ten_gig){
if (detectormacadd != getDetectorMAC()){
printf("*************************************************\n"); printf("*************************************************\n");
printf("WARNING: actual detector mac address %llx does not match the one from client %llx\n",getDetectorMAC(),detectormacadd); printf("WARNING: actual detector mac address %llx does not match the one from client %llx\n",getDetectorMAC(),detectormacadd);
detectormacadd = getDetectorMAC(); detectormacadd = getDetectorMAC();
printf("WARNING: Matched detectormac to the hardware mac now\n"); printf("WARNING: Matched detectormac to the hardware mac now\n");
printf("*************************************************\n"); printf("*************************************************\n");
} }
if (detipad != getDetectorIP()){
printf("*************************************************\n");
printf("WARNING: actual detector ip address %x does not match the one from client %x\n",getDetectorIP(),detipad);
detipad = getDetectorIP();
printf("WARNING: Matched detector ip to the hardware ip now\n");
printf("*************************************************\n");
}
}
char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50]; char src_mac[50], src_ip[50],dst_mac[50], dst_ip[50];
int src_port = 0xE185; int src_port = 0xE185;

View File

@ -28,8 +28,9 @@ int getNModBoard(enum dimension arg);
int64_t getModuleId(enum idMode arg, int imod); int64_t getModuleId(enum idMode arg, int imod);
int64_t getDetectorId(enum idMode arg); int64_t getDetectorId(enum idMode arg);
u_int64_t getDetectorMAC();
int getDetectorNumber(); int getDetectorNumber();
u_int64_t getDetectorMAC();
int getDetectorIP();
int moduleTest( enum digitalTestMode arg, int imod); int moduleTest( enum digitalTestMode arg, int imod);
int detectorTest( enum digitalTestMode arg); int detectorTest( enum digitalTestMode arg);