mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-23 11:10:41 +02:00
updated getting detector mac address for gotthard
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@262 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
32621b1916
commit
e0ad54dd46
@ -706,34 +706,19 @@ int setContinousReadOut(int d) {
|
|||||||
|
|
||||||
|
|
||||||
u_int64_t getDetectorNumber() {
|
u_int64_t getDetectorNumber() {
|
||||||
|
char output[255],mac[255]="";
|
||||||
FILE *fp=NULL;
|
u_int64_t res=0;
|
||||||
u_int64_t res;
|
FILE* sysFile = popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r");
|
||||||
char line[150];
|
fgets(output, sizeof(output), sysFile);
|
||||||
int a[6];
|
pclose(sysFile);
|
||||||
|
//getting rid of ":"
|
||||||
int n=0, i;
|
char * pch;
|
||||||
//u_int64_t a0,a1,a2,a3,a4,a5,n=0;
|
pch = strtok (output,":");
|
||||||
fp=fopen("/etc/conf.d/mac","r");
|
while (pch != NULL){
|
||||||
if (fp==NULL) {
|
strcat(mac,pch);
|
||||||
printf("could not ope MAC file\n");;
|
pch = strtok (NULL, ":");
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
while (fgets(line,150,fp)) {
|
|
||||||
//MAC="00:40:8C:CD:00:00"
|
|
||||||
printf(line);
|
|
||||||
if (strstr(line,"MAC="))
|
|
||||||
n=sscanf(line,"MAC=\"%x:%x:%x:%x:%x:%x\"",a+5,a+4,a+3,a+2,a+1,a);
|
|
||||||
}
|
|
||||||
fclose(fp);
|
|
||||||
if (n!=6){
|
|
||||||
printf("could not scan MAC address\n");;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
res=0;
|
|
||||||
for (i=0; i<n; i++) {
|
|
||||||
res=(res<<8)+a[n-1-i];
|
|
||||||
}
|
}
|
||||||
|
sscanf(mac,"%llx",&res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user