mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
replaced old logger
This commit is contained in:
@ -25,13 +25,13 @@ int i2c_open(const char* file,unsigned int addr){
|
||||
//device file
|
||||
int fd = open( file, O_RDWR );
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Warning: Unable to open file %s\n",file));
|
||||
LOG(logERROR, ("Warning: Unable to open file %s\n",file));
|
||||
return -1;
|
||||
}
|
||||
|
||||
//device address
|
||||
if( ioctl( fd, I2C_SLAVE, addr&0x7F ) < 0 ) {
|
||||
FILE_LOG(logERROR, ("Warning: Unable to set slave address:0x%x \n",addr));
|
||||
LOG(logERROR, ("Warning: Unable to set slave address:0x%x \n",addr));
|
||||
return -2;
|
||||
}
|
||||
return fd;
|
||||
@ -45,17 +45,17 @@ int i2c_read(){
|
||||
|
||||
unsigned char buf = reg;
|
||||
if (write(fd, &buf, 1)!= 1){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to write read request to register %d\n", reg));
|
||||
LOG(logERROR, ("Warning: Unable to write read request to register %d\n", reg));
|
||||
return -1;
|
||||
}
|
||||
//read and update value (but old value read out)
|
||||
if(read(fd, &buf, 1) != 1){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
return -2;
|
||||
}
|
||||
//read again to read the updated value
|
||||
if(read(fd, &buf, 1) != 1){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
return -2;
|
||||
}
|
||||
close(fd);
|
||||
@ -76,7 +76,7 @@ int i2c_write(unsigned int value){
|
||||
buf[0] = reg;
|
||||
buf[1] = val;
|
||||
if (write(fd, buf, 2) != 2) {
|
||||
FILE_LOG(logERROR, ("Warning: Unable to write %d to register %d\n",val, reg));
|
||||
LOG(logERROR, ("Warning: Unable to write %d to register %d\n",val, reg));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -92,10 +92,10 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
int fd = open(PORTNAME, O_RDWR | O_NOCTTY | O_SYNC);
|
||||
if(fd < 0){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to open port %s\n", PORTNAME));
|
||||
LOG(logERROR, ("Warning: Unable to open port %s\n", PORTNAME));
|
||||
return -1;
|
||||
}
|
||||
FILE_LOG(logINFO, ("opened port at %s\n",PORTNAME));
|
||||
LOG(logINFO, ("opened port at %s\n",PORTNAME));
|
||||
|
||||
struct termios serial_conf;
|
||||
// reset structure
|
||||
@ -110,17 +110,17 @@ int main(int argc, char* argv[]) {
|
||||
serial_conf.c_lflag = ICANON;
|
||||
// flush input
|
||||
if(tcflush(fd, TCIOFLUSH) < 0){
|
||||
FILE_LOG(logERROR, ("Warning: error form tcflush %d\n", errno));
|
||||
LOG(logERROR, ("Warning: error form tcflush %d\n", errno));
|
||||
return 0;
|
||||
}
|
||||
// set new options for the port, TCSANOW:changes occur immediately without waiting for data to complete
|
||||
if(tcsetattr(fd, TCSANOW, &serial_conf) < 0){
|
||||
FILE_LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(tcsetattr(fd, TCSAFLUSH, &serial_conf) < 0){
|
||||
FILE_LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -130,25 +130,25 @@ int main(int argc, char* argv[]) {
|
||||
char buffer[BUFFERSIZE];
|
||||
memset(buffer,0,BUFFERSIZE);
|
||||
buffer[BUFFERSIZE-1] = '\n';
|
||||
FILE_LOG(logINFO, ("Ready...\n"));
|
||||
LOG(logINFO, ("Ready...\n"));
|
||||
|
||||
|
||||
while(ret != GOODBYE){
|
||||
memset(buffer,0,BUFFERSIZE);
|
||||
n = read(fd,buffer,BUFFERSIZE);
|
||||
FILE_LOG(logDEBUG1, ("Received %d Bytes\n", n));
|
||||
FILE_LOG(logINFO, ("Got message: '%s'\n",buffer));
|
||||
LOG(logDEBUG1, ("Received %d Bytes\n", n));
|
||||
LOG(logINFO, ("Got message: '%s'\n",buffer));
|
||||
|
||||
switch(buffer[0]){
|
||||
case '\0':
|
||||
FILE_LOG(logINFO, ("Got Start (Detector restart)\n"));
|
||||
LOG(logINFO, ("Got Start (Detector restart)\n"));
|
||||
break;
|
||||
case 's':
|
||||
FILE_LOG(logINFO, ("Got Start \n"));
|
||||
LOG(logINFO, ("Got Start \n"));
|
||||
break;
|
||||
case 'p':
|
||||
if (!sscanf(&buffer[1],"%d",&ival)){
|
||||
FILE_LOG(logERROR, ("Warning: cannot scan voltage value\n"));
|
||||
LOG(logERROR, ("Warning: cannot scan voltage value\n"));
|
||||
break;
|
||||
}
|
||||
// ok/ fail
|
||||
@ -158,9 +158,9 @@ int main(int argc, char* argv[]) {
|
||||
strcpy(buffer,"fail ");
|
||||
else
|
||||
strcpy(buffer,"success ");
|
||||
FILE_LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
FILE_LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
@ -173,17 +173,17 @@ int main(int argc, char* argv[]) {
|
||||
else
|
||||
strcpy(buffer,"success ");
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
FILE_LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
FILE_LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
//value
|
||||
memset(buffer,0,BUFFERSIZE);
|
||||
buffer[BUFFERSIZE-1] = '\n';
|
||||
if(ival >= 0){
|
||||
FILE_LOG(logINFO, ("Sending: '%d'\n",ival));
|
||||
LOG(logINFO, ("Sending: '%d'\n",ival));
|
||||
sprintf(buffer,"%d ",ival);
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
FILE_LOG(logINFO, ("Sent %d Bytes\n", n));
|
||||
}else FILE_LOG(logERROR, ("%s\n",buffer));
|
||||
LOG(logINFO, ("Sent %d Bytes\n", n));
|
||||
}else LOG(logERROR, ("%s\n",buffer));
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
@ -191,7 +191,7 @@ int main(int argc, char* argv[]) {
|
||||
ret = GOODBYE;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown Command. buffer:'%s'\n",buffer));
|
||||
LOG(logERROR, ("Unknown Command. buffer:'%s'\n",buffer));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ unsigned int BebInfo_GetSrcPort(struct BebInfo* bebInfo, int ten_gig) {return te
|
||||
|
||||
|
||||
void BebInfo_Print(struct BebInfo* bebInfo) {
|
||||
FILE_LOG(logINFO, (
|
||||
LOG(logINFO, (
|
||||
"%d) Beb Info:\n"
|
||||
"\tSerial Add: 0x%x\n"
|
||||
"\tMAC 1GbE: %s\n"
|
||||
@ -133,7 +133,7 @@ void Beb_Beb(int id) {
|
||||
|
||||
if (!Beb_InitBebInfos()) exit(1);
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Printing Beb infos:\n"));
|
||||
LOG(logDEBUG1, ("Printing Beb infos:\n"));
|
||||
unsigned int i;
|
||||
for(i=1;i<bebInfoSize;i++) BebInfo_Print(&beb_infos[i]);
|
||||
|
||||
@ -157,12 +157,12 @@ void Beb_GetModuleConfiguration(int* master, int* top, int* normal) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
} else {
|
||||
//read data
|
||||
ret = Beb_Read32(csp0base, MODULE_CONFIGURATION_MASK);
|
||||
FILE_LOG(logDEBUG1, ("Module Configuration OK\n"));
|
||||
FILE_LOG(logDEBUG1, ("Beb: value =0x%x\n",ret));
|
||||
LOG(logDEBUG1, ("Module Configuration OK\n"));
|
||||
LOG(logDEBUG1, ("Beb: value =0x%x\n",ret));
|
||||
if (ret&TOP_BIT_MASK) {
|
||||
*top = 1;
|
||||
Beb_top = 1;
|
||||
@ -215,7 +215,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_COUNTER_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Delay read counter fail\n"));
|
||||
LOG(logERROR, ("Delay read counter fail\n"));
|
||||
return;
|
||||
} else {
|
||||
//read data first time
|
||||
@ -227,7 +227,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
r_framepktMsbcounter = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
FILE_LOG(logDEBUG1, ("\nLeft\n"
|
||||
LOG(logDEBUG1, ("\nLeft\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
@ -245,7 +245,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
while(1) {
|
||||
maxtimer = MAX(MAX(l_txndelaycounter,l_framedelaycounter),MAX(r_txndelaycounter,r_framedelaycounter));
|
||||
maxtimer /= 100;
|
||||
FILE_LOG(logDEBUG1, ("Will wait for %d us\n",maxtimer));
|
||||
LOG(logDEBUG1, ("Will wait for %d us\n",maxtimer));
|
||||
usleep(maxtimer);
|
||||
|
||||
//read new values
|
||||
@ -257,7 +257,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
r_framepktMsbcounter_new = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter_new = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter_new = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
FILE_LOG(logDEBUG1, ("\nLeft\n"
|
||||
LOG(logDEBUG1, ("\nLeft\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
@ -288,7 +288,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("Detector has sent all data\n"));
|
||||
LOG(logINFO, ("Detector has sent all data\n"));
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
@ -310,14 +310,14 @@ int Beb_SetMasterViaSoftware() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Master FAIL\n"));
|
||||
LOG(logERROR, ("Set Master FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
|
||||
value|=MASTER_BIT;
|
||||
value|=OVERWRITE_HARDWARE_BIT;
|
||||
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,value);
|
||||
if (newval!=value) {
|
||||
FILE_LOG(logERROR, ("Could not set Master via Software\n"));
|
||||
LOG(logERROR, ("Could not set Master via Software\n"));
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
@ -343,14 +343,14 @@ int Beb_SetSlaveViaSoftware() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Slave FAIL\n"));
|
||||
LOG(logERROR, ("Set Slave FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
|
||||
value&=~MASTER_BIT;
|
||||
value|=OVERWRITE_HARDWARE_BIT;
|
||||
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,value);
|
||||
if (newval!=value) {
|
||||
FILE_LOG(logERROR, ("Could not set Slave via Software\n"));
|
||||
LOG(logERROR, ("Could not set Slave via Software\n"));
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
@ -371,11 +371,11 @@ int Beb_Activate(int enable) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Deactivate FAIL\n"));
|
||||
LOG(logERROR, ("Deactivate FAIL\n"));
|
||||
} else {
|
||||
if (enable > -1) {
|
||||
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
|
||||
FILE_LOG(logINFO, ("Deactivate register value before:%d\n",value));
|
||||
LOG(logINFO, ("Deactivate register value before:%d\n",value));
|
||||
if (enable)
|
||||
value&=~DEACTIVATE_BIT;
|
||||
else
|
||||
@ -384,9 +384,9 @@ int Beb_Activate(int enable) {
|
||||
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,value);
|
||||
if (newval!=value) {
|
||||
if (enable) {
|
||||
FILE_LOG(logERROR, ("Could not activate via Software\n"));
|
||||
LOG(logERROR, ("Could not activate via Software\n"));
|
||||
} else {
|
||||
FILE_LOG(logERROR, ("Could not deactivate via Software\n"));
|
||||
LOG(logERROR, ("Could not deactivate via Software\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -396,9 +396,9 @@ int Beb_Activate(int enable) {
|
||||
else ret = 1;
|
||||
if (enable == -1) {
|
||||
if (ret) {
|
||||
FILE_LOG(logINFOBLUE, ("Detector is active. Register value:%d\n", value));
|
||||
LOG(logINFOBLUE, ("Detector is active. Register value:%d\n", value));
|
||||
} else {
|
||||
FILE_LOG(logERROR, ("Detector is deactivated! Register value:%d\n", value));
|
||||
LOG(logERROR, ("Detector is deactivated! Register value:%d\n", value));
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,7 +430,7 @@ int Beb_Set32bitOverflow(int val) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set overflow flag in 32 bit mode. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set overflow flag in 32 bit mode. FAIL\n"));
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
@ -459,7 +459,7 @@ int Beb_GetTenGigaFlowControl() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get ten giga flow control. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get ten giga flow control. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@ -471,13 +471,13 @@ int Beb_GetTenGigaFlowControl() {
|
||||
}
|
||||
|
||||
int Beb_SetTenGigaFlowControl(int value) {
|
||||
FILE_LOG(logINFO, ("Setting ten giga flow control to %d\n", value));
|
||||
LOG(logINFO, ("Setting ten giga flow control to %d\n", value));
|
||||
value = value == 0 ? 0 : 1;
|
||||
u_int32_t offset = FLOW_REG_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set ten giga flow control. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set ten giga flow control. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
// reset bit
|
||||
@ -499,7 +499,7 @@ int Beb_GetTransmissionDelayFrame() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get transmission delay frame. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get transmission delay frame. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@ -509,16 +509,16 @@ int Beb_GetTransmissionDelayFrame() {
|
||||
}
|
||||
|
||||
int Beb_SetTransmissionDelayFrame(int value) {
|
||||
FILE_LOG(logINFO, ("Setting transmission delay frame to %d\n", value));
|
||||
LOG(logINFO, ("Setting transmission delay frame to %d\n", value));
|
||||
if (value < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid transmission delay frame value %d\n", value));
|
||||
LOG(logERROR, ("Invalid transmission delay frame value %d\n", value));
|
||||
return 0;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_FRAME_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set transmission delay frame. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set transmission delay frame. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
Beb_Write32(csp0base, offset, value);
|
||||
@ -532,7 +532,7 @@ int Beb_GetTransmissionDelayLeft() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get transmission delay left. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get transmission delay left. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@ -542,16 +542,16 @@ int Beb_GetTransmissionDelayLeft() {
|
||||
}
|
||||
|
||||
int Beb_SetTransmissionDelayLeft(int value) {
|
||||
FILE_LOG(logINFO, ("Setting transmission delay left to %d\n", value));
|
||||
LOG(logINFO, ("Setting transmission delay left to %d\n", value));
|
||||
if (value < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid transmission delay left value %d\n", value));
|
||||
LOG(logERROR, ("Invalid transmission delay left value %d\n", value));
|
||||
return 0;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_LEFT_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set transmission delay left. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set transmission delay left. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
Beb_Write32(csp0base, offset, value);
|
||||
@ -565,7 +565,7 @@ int Beb_GetTransmissionDelayRight() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get transmission delay right. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get transmission delay right. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@ -575,16 +575,16 @@ int Beb_GetTransmissionDelayRight() {
|
||||
}
|
||||
|
||||
int Beb_SetTransmissionDelayRight(int value) {
|
||||
FILE_LOG(logINFO, ("Setting transmission delay right to %d\n", value));
|
||||
LOG(logINFO, ("Setting transmission delay right to %d\n", value));
|
||||
if (value < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid transmission delay right value %d\n", value));
|
||||
LOG(logERROR, ("Invalid transmission delay right value %d\n", value));
|
||||
return 0;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_RIGHT_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set transmission delay right. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set transmission delay right. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
Beb_Write32(csp0base, offset, value);
|
||||
@ -617,12 +617,12 @@ int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val) {
|
||||
break;
|
||||
|
||||
|
||||
default: FILE_LOG(logERROR, ("Unrecognized mode in network parameter: %d\n",mode)); return -1;
|
||||
default: LOG(logERROR, ("Unrecognized mode in network parameter: %d\n",mode)); return -1;
|
||||
}
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set network parameter. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set network parameter. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
if (val > -1) {
|
||||
@ -655,11 +655,11 @@ int Beb_ResetToHardwareSettings() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Reset to Hardware Settings FAIL\n"));
|
||||
LOG(logERROR, ("Reset to Hardware Settings FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,0);
|
||||
if (value) {
|
||||
FILE_LOG(logERROR, ("Could not reset to hardware settings\n"));
|
||||
LOG(logERROR, ("Could not reset to hardware settings\n"));
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
@ -682,11 +682,11 @@ u_int32_t Beb_GetFirmwareRevision() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_VERSION);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Firmware Revision Read FAIL\n"));
|
||||
LOG(logERROR, ("Firmware Revision Read FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, FIRMWARE_VERSION_OFFSET);
|
||||
if (!value) {
|
||||
FILE_LOG(logERROR, ("Firmware Revision Number does not exist in this version\n"));
|
||||
LOG(logERROR, ("Firmware Revision Number does not exist in this version\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -706,11 +706,11 @@ u_int32_t Beb_GetFirmwareSoftwareAPIVersion() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_VERSION);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Firmware Software API Version Read FAIL\n"));
|
||||
LOG(logERROR, ("Firmware Software API Version Read FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, FIRMWARESOFTWARE_API_OFFSET);
|
||||
if (!value) {
|
||||
FILE_LOG(logERROR, ("Firmware Software API Version does not exist in this version\n"));
|
||||
LOG(logERROR, ("Firmware Software API Version does not exist in this version\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -731,14 +731,14 @@ void Beb_ResetFrameNumber() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Reset Frame Number FAIL\n"));
|
||||
LOG(logERROR, ("Reset Frame Number FAIL\n"));
|
||||
} else {
|
||||
//write a 1
|
||||
Beb_Write32(csp0base, FRAME_NUM_RESET_OFFSET, 1);
|
||||
usleep(100000); //100ms
|
||||
//write a 0
|
||||
Beb_Write32(csp0base, FRAME_NUM_RESET_OFFSET, 0);
|
||||
FILE_LOG(logINFO, ("Frame Number Reset OK\n"));
|
||||
LOG(logINFO, ("Frame Number Reset OK\n"));
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
@ -764,7 +764,7 @@ int Beb_InitBebInfos() {//file name at some point
|
||||
|
||||
int i0=Beb_detid,i1=0;
|
||||
if (Beb_GetBebInfoIndex(i0)) {
|
||||
FILE_LOG(logERROR, ("cant add beb. adding beb %d, beb number %d already added.\n",Beb_detid, i0));
|
||||
LOG(logERROR, ("cant add beb. adding beb %d, beb number %d already added.\n",Beb_detid, i0));
|
||||
exit(0);
|
||||
}
|
||||
struct BebInfo b1;
|
||||
@ -798,7 +798,7 @@ int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac
|
||||
/******* if (!i) return 0;****************************/ //i must be greater than 0, zero is the global send
|
||||
BebInfo_SetHeaderInfo(&beb_infos[i],ten_gig,src_mac,src_ip,src_port);
|
||||
|
||||
FILE_LOG(logINFO, ("Printing Beb info number (%d) :\n",i));
|
||||
LOG(logINFO, ("Printing Beb info number (%d) :\n",i));
|
||||
BebInfo_Print(&beb_infos[i]);
|
||||
|
||||
return 1;
|
||||
@ -813,7 +813,7 @@ int Beb_CheckSourceStuffBebInfo() {
|
||||
if (!Beb_SetHeaderData(
|
||||
BebInfo_GetBebNumber(&beb_infos[i]),0,"00:00:00:00:00:00","10.0.0.1",20000)||
|
||||
!Beb_SetHeaderData(BebInfo_GetBebNumber(&beb_infos[i]),1,"00:00:00:00:00:00","10.0.0.1",20000)) {
|
||||
FILE_LOG(logINFO, ("Error in BebInfo for module number %d.\n",BebInfo_GetBebNumber(&beb_infos[i])));
|
||||
LOG(logINFO, ("Error in BebInfo for module number %d.\n",BebInfo_GetBebNumber(&beb_infos[i])));
|
||||
BebInfo_Print(&beb_infos[i]);
|
||||
return 0;
|
||||
}
|
||||
@ -826,10 +826,10 @@ unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb) {
|
||||
unsigned int i;
|
||||
for(i=1;i<bebInfoSize;i++)
|
||||
if (beb_numb==BebInfo_GetBebNumber(&beb_infos[i])) {
|
||||
FILE_LOG(logDEBUG1, ("*****found beb index:%d, for beb number:%d\n",i,beb_numb));
|
||||
LOG(logDEBUG1, ("*****found beb index:%d, for beb number:%d\n",i,beb_numb));
|
||||
return i;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("*****Returning 0\n"));
|
||||
LOG(logDEBUG1, ("*****Returning 0\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -841,7 +841,7 @@ int Beb_WriteTo(unsigned int index) {
|
||||
return 1;
|
||||
|
||||
if (index>=bebInfoSize) {
|
||||
FILE_LOG(logERROR, ("WriteTo index error.\n"));
|
||||
LOG(logERROR, ("WriteTo index error.\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -886,7 +886,7 @@ int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header
|
||||
|
||||
int fd = Beb_open(&csp0base,bram_phy_addr);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set up UDP Header FAIL\n"));
|
||||
LOG(logERROR, ("Set up UDP Header FAIL\n"));
|
||||
} else {
|
||||
//read data
|
||||
memcpy(csp0base+header_number*16, &udp_header, sizeof(udp_header));
|
||||
@ -932,18 +932,18 @@ int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char*
|
||||
*/
|
||||
|
||||
if (!Beb_SetMAC(src_mac,&(udp_header.src_mac[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Source MAC to %s\n",src_mac));
|
||||
LOG(logINFO, ("Setting Source MAC to %s\n",src_mac));
|
||||
if (!Beb_SetIP(src_ip,&(udp_header.src_ip[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Source IP to %s\n",src_ip));
|
||||
LOG(logINFO, ("Setting Source IP to %s\n",src_ip));
|
||||
if (!Beb_SetPortNumber(src_port,&(udp_header.src_port[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Source port to %d\n",src_port));
|
||||
LOG(logINFO, ("Setting Source port to %d\n",src_port));
|
||||
|
||||
if (!Beb_SetMAC(dst_mac,&(udp_header.dst_mac[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Destination MAC to %s\n",dst_mac));
|
||||
LOG(logINFO, ("Setting Destination MAC to %s\n",dst_mac));
|
||||
if (!Beb_SetIP(dst_ip,&(udp_header.dst_ip[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Destination IP to %s\n",dst_ip));
|
||||
LOG(logINFO, ("Setting Destination IP to %s\n",dst_ip));
|
||||
if (!Beb_SetPortNumber(dst_port,&(udp_header.dst_port[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Destination port to %d\n",dst_port));
|
||||
LOG(logINFO, ("Setting Destination port to %d\n",dst_port));
|
||||
|
||||
|
||||
Beb_AdjustIPChecksum(&udp_header);
|
||||
@ -968,7 +968,7 @@ int Beb_SetMAC(char* mac, uint8_t* dst_ptr) {
|
||||
char *pch = strtok (macVal,":");
|
||||
while (pch != NULL) {
|
||||
if (strlen(pch)!=2) {
|
||||
FILE_LOG(logERROR, ("Error: in mac address -> %s\n",macVal));
|
||||
LOG(logERROR, ("Error: in mac address -> %s\n",macVal));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -987,7 +987,7 @@ int Beb_SetIP(char* ip, uint8_t* dst_ptr) {
|
||||
char *pch = strtok (ipVal,".");
|
||||
while (pch != NULL) {
|
||||
if (((i!=3) && ((strlen(pch)>3) || (strlen(pch)<1))) || ((i==3)&&((strlen(pch)<1) || (strlen(pch) > 3)))) {
|
||||
FILE_LOG(logERROR, ("Error: in ip address -> %s\n",ipVal));
|
||||
LOG(logERROR, ("Error: in ip address -> %s\n",ipVal));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1050,11 +1050,11 @@ int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, i
|
||||
|
||||
|
||||
Beb_send_data[1] = 0x62000000 | (!stop_read_when_fifo_empty) << 27 | (ten_gig==1) << 24 | packet_size << 14 | dst_number << 8 | npackets;
|
||||
FILE_LOG(logDEBUG1, ("Beb_send_data[1]:%X\n",Beb_send_data[1]));
|
||||
LOG(logDEBUG1, ("Beb_send_data[1]:%X\n",Beb_send_data[1]));
|
||||
Beb_send_data[2] = 0;
|
||||
|
||||
Beb_SwapDataFun(0,2,&(Beb_send_data[1]));
|
||||
FILE_LOG(logDEBUG1, ("Beb_send_data[1] Swapped:%X\n",Beb_send_data[1]));
|
||||
LOG(logDEBUG1, ("Beb_send_data[1] Swapped:%X\n",Beb_send_data[1]));
|
||||
|
||||
if (Beb_activated) {
|
||||
if (!Beb_WriteTo(i)) return 0;
|
||||
@ -1085,7 +1085,7 @@ int Beb_StopAcquisition()
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_CMD_GENERATOR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Beb Stop Acquisition FAIL\n"));
|
||||
LOG(logERROR, ("Beb Stop Acquisition FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
//find value
|
||||
@ -1098,7 +1098,7 @@ int Beb_StopAcquisition()
|
||||
Beb_Write32(csp0base, (LEFT_OFFSET + STOP_ACQ_OFFSET),(valuel&(~STOP_ACQ_BIT)));
|
||||
Beb_Write32(csp0base, (RIGHT_OFFSET + STOP_ACQ_OFFSET),(valuer&(~STOP_ACQ_BIT)));
|
||||
|
||||
FILE_LOG(logINFO, ("Beb Stop Acquisition OK\n"));
|
||||
LOG(logINFO, ("Beb Stop Acquisition OK\n"));
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
@ -1116,7 +1116,7 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
unsigned int nl = Beb_readNLines;
|
||||
unsigned int npackets = (nl * maxnp) / maxnl;
|
||||
if ((nl * maxnp) % maxnl) {
|
||||
FILE_LOG(logERROR, ("Read N Lines is incorrect. Switching to Full Image Readout\n"));
|
||||
LOG(logERROR, ("Read N Lines is incorrect. Switching to Full Image Readout\n"));
|
||||
npackets = maxnp;
|
||||
}
|
||||
int in_two_requests = (npackets > MAX_PACKETS_PER_REQUEST) ? 1 : 0;
|
||||
@ -1126,8 +1126,8 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
unsigned int header_size = 4; //4*64 bits
|
||||
unsigned int packet_size = ten_gig ? 0x200 : 0x80; // 4k or 1k packets
|
||||
|
||||
FILE_LOG(logDEBUG1, ("----Beb_RequestNImages Start----\n"));
|
||||
FILE_LOG(logINFO, ("beb_number:%d, ten_gig:%d,dst_number:%d, npackets:%d, "
|
||||
LOG(logDEBUG1, ("----Beb_RequestNImages Start----\n"));
|
||||
LOG(logINFO, ("beb_number:%d, ten_gig:%d,dst_number:%d, npackets:%d, "
|
||||
"Beb_bit_mode:%d, header_size:%d, nimages:%d, test_just_send_out_packets_no_wait:%d\n",
|
||||
beb_number, ten_gig, dst_number, npackets, Beb_bit_mode, header_size,
|
||||
nimages, test_just_send_out_packets_no_wait));
|
||||
@ -1138,13 +1138,13 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_CMD_GENERATOR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Beb Request N Images FAIL\n"));
|
||||
LOG(logERROR, ("Beb Request N Images FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < 10; i++)
|
||||
FILE_LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
}
|
||||
// Generating commands
|
||||
u_int32_t send_header_command = 0x62000000 | (!test_just_send_out_packets_no_wait) << 27 | (ten_gig==1) << 24 | header_size << 14 | 0;
|
||||
@ -1152,8 +1152,8 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < 10; i++)
|
||||
FILE_LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
FILE_LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
}
|
||||
//"0x20 << 8" is dst_number (0x00 for left, 0x20 for right)
|
||||
//Left
|
||||
@ -1181,12 +1181,12 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < 10; i++)
|
||||
FILE_LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4)))); //*(ptrl+i));
|
||||
FILE_LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4)))); //*(ptrl+i));
|
||||
LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
}
|
||||
Beb_close(fd,csp0base);
|
||||
|
||||
FILE_LOG(logDEBUG1, ("----Beb_RequestNImages----\n"));
|
||||
LOG(logDEBUG1, ("----Beb_RequestNImages----\n"));
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -1194,7 +1194,7 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
|
||||
|
||||
int Beb_Test(unsigned int beb_number) {
|
||||
FILE_LOG(logINFO, ("Testing module number: %d\n",beb_number));
|
||||
LOG(logINFO, ("Testing module number: %d\n",beb_number));
|
||||
|
||||
|
||||
//int SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, string dst_mac, string dst_ip, unsigned int dst_port) {
|
||||
@ -1202,14 +1202,14 @@ int Beb_Test(unsigned int beb_number) {
|
||||
|
||||
unsigned int index = Beb_GetBebInfoIndex(beb_number);
|
||||
if (!index) {
|
||||
FILE_LOG(logERROR, ("Error beb number (%d)not in list????\n",beb_number));
|
||||
LOG(logERROR, ("Error beb number (%d)not in list????\n",beb_number));
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int i;
|
||||
for(i=0;i<64;i++) {
|
||||
if (!Beb_SetUpUDPHeader(beb_number,0,i,"60:fb:42:f4:e3:d2","129.129.205.186",22000+i)) {
|
||||
FILE_LOG(logERROR, ("Error setting up header table....\n"));
|
||||
LOG(logERROR, ("Error setting up header table....\n"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1217,7 +1217,7 @@ int Beb_Test(unsigned int beb_number) {
|
||||
// SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty=1);
|
||||
for(i=0;i<64;i++) {
|
||||
if (!Beb_SendMultiReadRequest(beb_number,i%3+1,0,i,1,0,1)) {
|
||||
FILE_LOG(logERROR, ("Error requesting data....\n"));
|
||||
LOG(logERROR, ("Error requesting data....\n"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1237,7 +1237,7 @@ int Beb_GetBebFPGATemp()
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_SYSMON_0_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
} else {
|
||||
//read data
|
||||
ret = Beb_Read32(csp0base, FPGA_TEMP_OFFSET);
|
||||
@ -1255,11 +1255,11 @@ void Beb_SetDetectorNumber(uint32_t detid) {
|
||||
return;
|
||||
|
||||
uint32_t swapid = Beb_swap_uint16(detid);
|
||||
//FILE_LOG(logINFO, "detector id %d swapped %d\n", detid, swapid));
|
||||
//LOG(logINFO, "detector id %d swapped %d\n", detid, swapid));
|
||||
u_int32_t* csp0base=0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
return;
|
||||
} else {
|
||||
uint32_t value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
|
||||
@ -1267,24 +1267,24 @@ void Beb_SetDetectorNumber(uint32_t detid) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
|
||||
if ((value & UDP_HEADER_ID_MSK) != ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) {
|
||||
FILE_LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
}
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
|
||||
value &= UDP_HEADER_X_MSK; // to keep previous x value
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
|
||||
if ((value & UDP_HEADER_ID_MSK) != ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) {
|
||||
FILE_LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
}
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
FILE_LOG(logINFO, ("Detector id %d set in UDP Header\n\n", detid));
|
||||
LOG(logINFO, ("Detector id %d set in UDP Header\n\n", detid));
|
||||
}
|
||||
|
||||
int Beb_SetQuad(int value) {
|
||||
if (value < 0)
|
||||
return OK;
|
||||
FILE_LOG(logINFO, ("Setting Quad to %d in Beb\n", value));
|
||||
LOG(logINFO, ("Setting Quad to %d in Beb\n", value));
|
||||
Beb_quadEnable = (value == 0 ? 0 : 1);
|
||||
return Beb_SetDetectorPosition(Beb_positions);
|
||||
}
|
||||
@ -1300,7 +1300,7 @@ int* Beb_GetDetectorPosition() {
|
||||
int Beb_SetDetectorPosition(int pos[]) {
|
||||
if (!Beb_activated)
|
||||
return OK;
|
||||
FILE_LOG(logINFO, ("Got Position values %d %d...\n", pos[0],pos[1]));
|
||||
LOG(logINFO, ("Got Position values %d %d...\n", pos[0],pos[1]));
|
||||
|
||||
// save positions
|
||||
Beb_positions[0] = pos[0];
|
||||
@ -1321,7 +1321,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Detector Position FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector Position FAIL\n"));
|
||||
return FAIL;
|
||||
} else {
|
||||
uint32_t value = 0;
|
||||
@ -1333,7 +1333,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
|
||||
if ((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set row position for left port\n"));
|
||||
LOG(logERROR, ("Could not set row position for left port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
// x right
|
||||
@ -1343,7 +1343,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
|
||||
if ((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set row position for right port\n"));
|
||||
LOG(logERROR, ("Could not set row position for right port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
@ -1356,7 +1356,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
|
||||
if ((value & UDP_HEADER_Y_MSK) != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set column position for left port\n"));
|
||||
LOG(logERROR, ("Could not set column position for left port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
@ -1367,7 +1367,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
|
||||
if ((value & UDP_HEADER_Y_MSK) != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set column position for right port\n"));
|
||||
LOG(logERROR, ("Could not set column position for right port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
@ -1376,7 +1376,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
if (ret == OK) {
|
||||
FILE_LOG(logINFO, ("Position set to...\n"
|
||||
LOG(logINFO, ("Position set to...\n"
|
||||
"\tLeft: [%d, %d]\n"
|
||||
"\tRight:[%d, %d]\n",
|
||||
posLeft[0], posLeft[1], posRight[0], posRight[1]));
|
||||
@ -1390,12 +1390,12 @@ int Beb_SetStartingFrameNumber(uint64_t value) {
|
||||
Beb_deactivatedStartFrameNumber = value;
|
||||
return OK;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Setting start frame number: %llu\n", (long long unsigned int)value));
|
||||
LOG(logINFO, ("Setting start frame number: %llu\n", (long long unsigned int)value));
|
||||
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Start Frame Number FAIL\n"));
|
||||
LOG(logERROR, ("Set Start Frame Number FAIL\n"));
|
||||
return FAIL;
|
||||
}
|
||||
// since the read is not implemented in firmware yet
|
||||
@ -1407,7 +1407,7 @@ int Beb_SetStartingFrameNumber(uint64_t value) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_FRAME_NUMBER_MSB_OFST, (valueInFirmware >> 32) & (0xffffffff));
|
||||
Beb_close(fd,csp0base);
|
||||
|
||||
FILE_LOG(logINFO, ("Going to reset Frame Number\n"));
|
||||
LOG(logINFO, ("Going to reset Frame Number\n"));
|
||||
Beb_ResetFrameNumber();
|
||||
return OK;
|
||||
}
|
||||
@ -1418,11 +1418,11 @@ int Beb_GetStartingFrameNumber(uint64_t* retval, int tengigaEnable) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Getting start frame number\n"));
|
||||
LOG(logDEBUG1, ("Getting start frame number\n"));
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_COUNTER_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Get Start Frame Number FAIL\n"));
|
||||
LOG(logERROR, ("Get Start Frame Number FAIL\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1440,7 +1440,7 @@ int Beb_GetStartingFrameNumber(uint64_t* retval, int tengigaEnable) {
|
||||
|
||||
Beb_close(fd,csp0base);
|
||||
if (left1g != right1g) {
|
||||
FILE_LOG(logERROR, ("Retrieved inconsistent frame numbers from 1g left %llu and right %llu\n",
|
||||
LOG(logERROR, ("Retrieved inconsistent frame numbers from 1g left %llu and right %llu\n",
|
||||
(long long int)left1g, (long long int)right1g));
|
||||
*retval = (left1g > right1g) ? left1g : right1g; // give max to set it to when stopping acq & different value
|
||||
return -2; // to differentiate between failed address mapping
|
||||
@ -1461,7 +1461,7 @@ int Beb_GetStartingFrameNumber(uint64_t* retval, int tengigaEnable) {
|
||||
++right10g; // increment for firmware
|
||||
|
||||
if (left10g != right10g) {
|
||||
FILE_LOG(logERROR, ("Retrieved inconsistent frame numbers from `0g left %llu and right %llu\n",
|
||||
LOG(logERROR, ("Retrieved inconsistent frame numbers from `0g left %llu and right %llu\n",
|
||||
(long long int)left10g, (long long int)right10g));
|
||||
*retval = (left10g > right10g) ? left10g : right10g; // give max to set it to when stopping acq & different value
|
||||
return -2; // to differentiate between failed address mapping
|
||||
@ -1484,15 +1484,15 @@ int Beb_open(u_int32_t** csp0base, u_int32_t offset) {
|
||||
|
||||
int fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
if (fd == -1) {
|
||||
FILE_LOG(logERROR, ("\nCan't find /dev/mem!\n"));
|
||||
LOG(logERROR, ("\nCan't find /dev/mem!\n"));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1, ("/dev/mem opened\n"));
|
||||
LOG(logDEBUG1, ("/dev/mem opened\n"));
|
||||
*csp0base = (u_int32_t*)mmap(0, BEB_MMAP_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, offset);
|
||||
if (*csp0base == MAP_FAILED) {
|
||||
FILE_LOG(logERROR, ("\nCan't map memmory area!!\n"));
|
||||
LOG(logERROR, ("\nCan't map memmory area!!\n"));
|
||||
fd = -1;
|
||||
}
|
||||
else FILE_LOG(logDEBUG1, ("CSP0 mapped %p\n",(void*)*csp0base));
|
||||
else LOG(logDEBUG1, ("CSP0 mapped %p\n",(void*)*csp0base));
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -55,7 +55,7 @@ void Feb_Interface_SendCompleteList(unsigned int n,unsigned int* list) {
|
||||
int Feb_Interface_WriteTo(unsigned int ch) {
|
||||
if (ch>0xfff) return 0;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("FIW ch %d\n", ch));
|
||||
LOG(logDEBUG1, ("FIW ch %d\n", ch));
|
||||
|
||||
Feb_Interface_send_data_raw[0] = 0x8fff0000;
|
||||
if (Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0;
|
||||
@ -176,7 +176,7 @@ int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num, unsign
|
||||
start_address &= 0x3fff;
|
||||
nwrites &= 0x3ff;
|
||||
if (!nwrites||nwrites>Feb_Interface_send_buffer_size-2) {
|
||||
FILE_LOG(logERROR, ("invalid nwrites:%d\n",nwrites));
|
||||
LOG(logERROR, ("invalid nwrites:%d\n",nwrites));
|
||||
return 0;
|
||||
}//*d-1026
|
||||
|
||||
|
@ -8,18 +8,18 @@
|
||||
|
||||
|
||||
void Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr) {
|
||||
FILE_LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n"));
|
||||
LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n"));
|
||||
ll->ll_fifo_base=0;
|
||||
ll->ll_fifo_ctrl_reg=0;
|
||||
if (Local_Init(ll,ll_fifo_badr)) {
|
||||
Local_Reset(ll);
|
||||
FILE_LOG(logDEBUG1, ("\tFIFO Status : 0x%08x\n\n\n", Local_StatusVector(ll)));
|
||||
} else FILE_LOG(logERROR, ("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr));
|
||||
LOG(logDEBUG1, ("\tFIFO Status : 0x%08x\n\n\n", Local_StatusVector(ll)));
|
||||
} else LOG(logERROR, ("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr));
|
||||
}
|
||||
|
||||
|
||||
void Local_LocalLinkInterface(struct LocalLinkInterface* ll) {
|
||||
FILE_LOG(logDEBUG1, ("Initializing new memory\n"));
|
||||
LOG(logDEBUG1, ("Initializing new memory\n"));
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ int Local_Reset(struct LocalLinkInterface* ll) {
|
||||
|
||||
int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask) {
|
||||
ll->ll_fifo_ctrl_reg |= rst_mask;
|
||||
FILE_LOG(logDEBUG1, ("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg));
|
||||
LOG(logDEBUG1, ("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg));
|
||||
|
||||
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
|
||||
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
|
||||
@ -90,9 +90,9 @@ int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buf
|
||||
last_word = (buffer_len-1)/4;
|
||||
word_ptr = (unsigned int *)buffer;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base));
|
||||
LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base));
|
||||
for (i=0; i < buffer_len/4; i++)
|
||||
FILE_LOG(logDEBUG1, ("%.8X ",*(((unsigned *) buffer)+i)));
|
||||
LOG(logDEBUG1, ("%.8X ",*(((unsigned *) buffer)+i)));
|
||||
|
||||
while (words_send <= last_word)
|
||||
{
|
||||
@ -101,7 +101,7 @@ int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buf
|
||||
status = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
|
||||
if ((status & PLB_LL_FIFO_STATUS_ALMOSTFULL) == 0) vacancy = 1;
|
||||
if (vacancy == 0) {
|
||||
FILE_LOG(logERROR, ("Fifo full!\n"));
|
||||
LOG(logERROR, ("Fifo full!\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
volatile unsigned int fifo_val;
|
||||
int sof = 0;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("LL Read - If: %X - Data: ",ll->ll_fifo_base));
|
||||
LOG(logDEBUG1, ("LL Read - If: %X - Data: ",ll->ll_fifo_base));
|
||||
|
||||
word_ptr = (unsigned int *)buffer;
|
||||
do
|
||||
@ -162,7 +162,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
{
|
||||
if ( (buffer_len >> 2) > buffer_ptr)
|
||||
{
|
||||
FILE_LOG(logDEBUG1, ("%.8X ", fifo_val));
|
||||
LOG(logDEBUG1, ("%.8X ", fifo_val));
|
||||
word_ptr[buffer_ptr++] = fifo_val; //write to buffer
|
||||
}
|
||||
else
|
||||
@ -174,7 +174,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
if (status & PLB_LL_FIFO_STATUS_LL_EOF)
|
||||
{
|
||||
len = (buffer_ptr << 2) -3 + ( (status & PLB_LL_FIFO_STATUS_LL_REM)>>PLB_LL_FIFO_STATUS_LL_REM_SHIFT );
|
||||
FILE_LOG(logDEBUG1, ("Len: %d\n",len));
|
||||
LOG(logDEBUG1, ("Len: %d\n",len));
|
||||
buffer_ptr = 0;
|
||||
return len;
|
||||
}
|
||||
@ -207,11 +207,11 @@ int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
|
||||
do{
|
||||
len = Local_Read(ll,rec_buff_len,rec_buffer);
|
||||
FILE_LOG(logDEBUG1, ("receive length: %i\n",len));
|
||||
LOG(logDEBUG1, ("receive length: %i\n",len));
|
||||
|
||||
if (len > 0) {
|
||||
rec_buffer[len]=0;
|
||||
FILE_LOG(logINFO, ("%s\n", (char*) rec_buffer));
|
||||
LOG(logINFO, ("%s\n", (char*) rec_buffer));
|
||||
}
|
||||
} while(len > 0);
|
||||
|
||||
|
@ -107,7 +107,7 @@ void basictests() {
|
||||
initCheckDone = 0;
|
||||
memset(initErrorMessage, 0, MAX_STR_LENGTH);
|
||||
#ifdef VIRTUAL
|
||||
FILE_LOG(logINFOBLUE, ("************ EIGER Virtual Server *****************\n\n"));
|
||||
LOG(logINFOBLUE, ("************ EIGER Virtual Server *****************\n\n"));
|
||||
#endif
|
||||
uint32_t ipadd = getDetectorIP();
|
||||
uint64_t macadd = getDetectorMAC();
|
||||
@ -116,7 +116,7 @@ void basictests() {
|
||||
int64_t sw_fw_apiversion = getFirmwareAPIVersion();
|
||||
int64_t client_sw_apiversion = getClientServerAPIVersion();
|
||||
|
||||
FILE_LOG(logINFOBLUE, ("**************** EIGER Server *********************\n\n"
|
||||
LOG(logINFOBLUE, ("**************** EIGER Server *********************\n\n"
|
||||
"Detector IP Addr:\t\t 0x%x\n"
|
||||
"Detector MAC Addr:\t\t 0x%llx\n"
|
||||
|
||||
@ -150,7 +150,7 @@ void basictests() {
|
||||
//cant read versions
|
||||
if (!fwversion || !sw_fw_apiversion) {
|
||||
strcpy(initErrorMessage, "Cant read versions from FPGA. Please update firmware.\n");
|
||||
FILE_LOG(logERROR, (initErrorMessage));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
@ -161,7 +161,7 @@ void basictests() {
|
||||
"Please update detector software (min. %lld) to be compatible with this firmware.\n",
|
||||
(long long int)sw_fw_apiversion,
|
||||
(long long int)REQUIRED_FIRMWARE_VERSION);
|
||||
FILE_LOG(logERROR, (initErrorMessage));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
@ -172,11 +172,11 @@ void basictests() {
|
||||
"Please update firmware (min. %lld) to be compatible with this server.\n",
|
||||
(long long int)fwversion,
|
||||
(long long int)REQUIRED_FIRMWARE_VERSION);
|
||||
FILE_LOG(logERROR, (initErrorMessage));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Compatibility - success\n"));
|
||||
LOG(logINFO, ("Compatibility - success\n"));
|
||||
}
|
||||
|
||||
|
||||
@ -250,7 +250,7 @@ u_int64_t getDetectorMAC() {
|
||||
//increment by 1 for 10g
|
||||
if (send_to_ten_gig)
|
||||
res++;
|
||||
//FILE_LOG(logINFO, ("mac:%llx\n",res));
|
||||
//LOG(logINFO, ("mac:%llx\n",res));
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -281,7 +281,7 @@ u_int32_t getDetectorIP() {
|
||||
}
|
||||
strcpy(output,temp);
|
||||
sscanf(output, "%x", &res);
|
||||
//FILE_LOG(logINFO, ("ip:%x\n",res));
|
||||
//LOG(logINFO, ("ip:%x\n",res));
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -312,10 +312,10 @@ void initControlServer() {
|
||||
if (Feb_Control_OpenSerialCommunication())
|
||||
;// Feb_Control_CloseSerialCommunication();
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
|
||||
LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
|
||||
Beb_Beb(detid);
|
||||
Beb_SetDetectorNumber(getDetectorNumber());
|
||||
FILE_LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
|
||||
LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
|
||||
|
||||
setupDetector();
|
||||
// activate (if it gets ip) (later FW will deactivate at startup)
|
||||
@ -340,7 +340,7 @@ void initStopServer() {
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
Feb_Control_Init(master,top,normal,getDetectorNumber());
|
||||
FILE_LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
||||
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
||||
// activate (if it gets ip) (later FW will deactivate at startup)
|
||||
// also needed for stop server for status
|
||||
if (getDetectorIP() != 0) {
|
||||
@ -368,7 +368,7 @@ void getModuleConfiguration() {
|
||||
#else
|
||||
normal = 1;
|
||||
#endif
|
||||
FILE_LOG(logINFOBLUE, ("Module: %s %s %s\n",
|
||||
LOG(logINFOBLUE, ("Module: %s %s %s\n",
|
||||
(top ? "TOP" : "BOTTOM"),
|
||||
(master ? "MASTER" : "SLAVE"),
|
||||
(normal ? "NORMAL" : "SPECIAL")));
|
||||
@ -379,7 +379,7 @@ void getModuleConfiguration() {
|
||||
int *n=&normal;
|
||||
Beb_GetModuleConfiguration(m,t,n);
|
||||
if (isControlServer) {
|
||||
FILE_LOG(logINFOBLUE, ("Module: %s %s %s\n",
|
||||
LOG(logINFOBLUE, ("Module: %s %s %s\n",
|
||||
(top ? "TOP" : "BOTTOM"),
|
||||
(master ? "MASTER" : "SLAVE"),
|
||||
(normal ? "NORMAL" : "SPECIAL")));
|
||||
@ -392,7 +392,7 @@ void getModuleConfiguration() {
|
||||
pclose(sysFile);
|
||||
sscanf(output,"%u",&detid);
|
||||
if (isControlServer) {
|
||||
FILE_LOG(logINFOBLUE, ("Detector ID: %u\n\n", detid));
|
||||
LOG(logINFOBLUE, ("Detector ID: %u\n\n", detid));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -402,15 +402,15 @@ void getModuleConfiguration() {
|
||||
/* set up detector */
|
||||
|
||||
void allocateDetectorStructureMemory() {
|
||||
FILE_LOG(logINFO, ("This Server is for 1 Eiger half module (250k)\n\n"));
|
||||
LOG(logINFO, ("This Server is for 1 Eiger half module (250k)\n\n"));
|
||||
|
||||
//Allocation of memory
|
||||
detectorModules = malloc(sizeof(sls_detector_module));
|
||||
detectorChans = malloc(NCHIP*NCHAN*sizeof(int));
|
||||
detectorDacs = malloc(NDAC*sizeof(int));
|
||||
FILE_LOG(logDEBUG1, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules));
|
||||
FILE_LOG(logDEBUG1, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans));
|
||||
FILE_LOG(logDEBUG1, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs));
|
||||
LOG(logDEBUG1, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules));
|
||||
LOG(logDEBUG1, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans));
|
||||
LOG(logDEBUG1, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs));
|
||||
(detectorModules)->dacs = detectorDacs;
|
||||
(detectorModules)->chanregs = detectorChans;
|
||||
(detectorModules)->ndac = NDAC;
|
||||
@ -435,19 +435,19 @@ void setupDetector() {
|
||||
|
||||
allocateDetectorStructureMemory();
|
||||
//set dacs
|
||||
FILE_LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
{
|
||||
int i = 0;
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for(i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i,defaultvals[i],0);
|
||||
if ((detectorModules)->dacs[i] != defaultvals[i]) {
|
||||
FILE_LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], (detectorModules)->dacs[i]));
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], (detectorModules)->dacs[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FILE_LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
||||
LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
||||
//setting default measurement parameters
|
||||
setNumFrames(DEFAULT_NUM_FRAMES);
|
||||
setExpTime(DEFAULT_EXPTIME);
|
||||
@ -476,7 +476,7 @@ void setupDetector() {
|
||||
#ifndef VIRTUAL
|
||||
Feb_Control_CheckSetup();
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1, ("Setup detector done\n\n"));
|
||||
LOG(logDEBUG1, ("Setup detector done\n\n"));
|
||||
}
|
||||
|
||||
|
||||
@ -512,13 +512,13 @@ int readRegister(uint32_t offset, uint32_t* retval) {
|
||||
int setDynamicRange(int dr) {
|
||||
#ifdef VIRTUAL
|
||||
if (dr > 0) {
|
||||
FILE_LOG(logINFO, ("Setting dynamic range: %d\n", dr));
|
||||
LOG(logINFO, ("Setting dynamic range: %d\n", dr));
|
||||
eiger_dynamicrange = dr;
|
||||
}
|
||||
return eiger_dynamicrange;
|
||||
#else
|
||||
if (dr > 0) {
|
||||
FILE_LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr));
|
||||
LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr));
|
||||
if (Feb_Control_SetDynamicRange(dr)) {
|
||||
|
||||
//EigerSetBitMode(dr);
|
||||
@ -527,7 +527,7 @@ int setDynamicRange(int dr) {
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
if (Beb_SetUpTransferParameters(dr))
|
||||
eiger_dynamicrange = dr;
|
||||
else FILE_LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
else LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
}
|
||||
}
|
||||
//make sure back end and front end have the same bit mode
|
||||
@ -574,7 +574,7 @@ int getOverFlowMode() {
|
||||
|
||||
void setStoreInRamMode(int mode) {
|
||||
mode = (mode == 0 ? 0 : 1);
|
||||
FILE_LOG(logINFO, ("Setting Store in Ram mode to %d\n", mode));
|
||||
LOG(logINFO, ("Setting Store in Ram mode to %d\n", mode));
|
||||
eiger_storeinmem = mode;
|
||||
}
|
||||
|
||||
@ -608,7 +608,7 @@ int getStartingFrameNumber(uint64_t* retval) {
|
||||
|
||||
void setNumFrames(int64_t val) {
|
||||
if (val > 0) {
|
||||
FILE_LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetNExposures((unsigned int)val * eiger_ntriggers)) {
|
||||
eiger_nexposures = val;
|
||||
@ -631,7 +631,7 @@ int64_t getNumFrames() {
|
||||
|
||||
void setNumTriggers(int64_t val) {
|
||||
if (val > 0) {
|
||||
FILE_LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetNExposures((unsigned int)val * eiger_nexposures)) {
|
||||
eiger_ntriggers = val;
|
||||
@ -652,7 +652,7 @@ int64_t getNumTriggers() {
|
||||
}
|
||||
|
||||
int setExpTime(int64_t val) {
|
||||
FILE_LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
Feb_Control_SetExposureTime(val/(1E9));
|
||||
#else
|
||||
@ -670,7 +670,7 @@ int64_t getExpTime() {
|
||||
}
|
||||
|
||||
int setPeriod(int64_t val) {
|
||||
FILE_LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
Feb_Control_SetExposurePeriod(val/(1E9));
|
||||
#else
|
||||
@ -688,7 +688,7 @@ int64_t getPeriod() {
|
||||
}
|
||||
|
||||
int setSubExpTime(int64_t val) {
|
||||
FILE_LOG(logINFO, ("Setting subexptime %lld ns\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting subexptime %lld ns\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
// calculate subdeadtime before settings subexptime
|
||||
int64_t subdeadtime = Feb_Control_GetSubFramePeriod() - Feb_Control_GetSubFrameExposureTime();
|
||||
@ -713,14 +713,14 @@ int64_t getSubExpTime() {
|
||||
}
|
||||
|
||||
int setDeadTime(int64_t val) {
|
||||
FILE_LOG(logINFO, ("Setting subdeadtime %lld ns\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting subdeadtime %lld ns\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
// get subexptime
|
||||
int64_t subexptime = Feb_Control_GetSubFrameExposureTime();
|
||||
#else
|
||||
int64_t subexptime = eiger_virtual_subexptime * 10;
|
||||
#endif
|
||||
FILE_LOG(logINFO, ("Setting sub period (subdeadtime(%lld)): %lldns\n",
|
||||
LOG(logINFO, ("Setting sub period (subdeadtime(%lld)): %lldns\n",
|
||||
(long long int)subexptime,
|
||||
(long long int)val),
|
||||
(long long int)(val + subexptime));
|
||||
@ -771,7 +771,7 @@ int64_t getMeasuredSubPeriod() {
|
||||
int setModule(sls_detector_module myMod, char* mess) {
|
||||
|
||||
|
||||
FILE_LOG(logINFO, ("Setting module with settings %d\n",myMod.reg));
|
||||
LOG(logINFO, ("Setting module with settings %d\n",myMod.reg));
|
||||
|
||||
// settings
|
||||
setSettings( (enum detectorSettings)myMod.reg);
|
||||
@ -781,9 +781,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
if (detectorModules) {
|
||||
if (copyModule(detectorModules,&myMod) == FAIL) {
|
||||
sprintf(mess, "Could not copy module\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@ -791,9 +791,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
// iodelay
|
||||
if (setIODelay(myMod.iodelay)!= myMod.iodelay) {
|
||||
sprintf(mess, "Could not set module. Could not set iodelay %d\n", myMod.iodelay);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -803,7 +803,7 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
else {
|
||||
// (loading a random trim file) (dont return fail)
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
}
|
||||
|
||||
// dacs
|
||||
@ -813,9 +813,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
setDAC((enum DACINDEX)i, myMod.dacs[i] , 0);
|
||||
if (myMod.dacs[i] != (detectorModules)->dacs[i]) {
|
||||
sprintf(mess, "Could not set module. Could not set dac %d\n", i);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@ -823,9 +823,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
// trimbits
|
||||
#ifndef VIRTUAL
|
||||
if (myMod.nchan == 0) {
|
||||
FILE_LOG(logINFO, ("Setting module without trimbits\n"));
|
||||
LOG(logINFO, ("Setting module without trimbits\n"));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Setting module with trimbits\n"));
|
||||
LOG(logINFO, ("Setting module with trimbits\n"));
|
||||
//includ gap pixels
|
||||
unsigned int tt[263680];
|
||||
int iy, ichip, ix, ip = 0, ich = 0;
|
||||
@ -844,9 +844,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
//set trimbits
|
||||
if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(), tt)) {
|
||||
sprintf(mess, "Could not set module. Could not set trimbits\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@ -859,9 +859,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
setRateCorrection(0);
|
||||
sprintf(mess,"Cannot set module. Cannot set Rate correction. "
|
||||
"No default tau provided. Deactivating Rate Correction\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@ -872,9 +872,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
int64_t retvalTau = setRateCorrection(myMod.tau);
|
||||
if (myMod.tau != retvalTau) {
|
||||
sprintf(mess, "Cannot set module. Could not set rate correction\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@ -923,7 +923,7 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
return thisSettings;
|
||||
}if (sett != GET_SETTINGS)
|
||||
thisSettings = sett;
|
||||
FILE_LOG(logINFO, ("Settings: %d\n", thisSettings));
|
||||
LOG(logINFO, ("Settings: %d\n", thisSettings));
|
||||
return thisSettings;
|
||||
}
|
||||
|
||||
@ -939,13 +939,13 @@ enum detectorSettings getSettings() {
|
||||
/* parameters - threshold */
|
||||
|
||||
int getThresholdEnergy() {
|
||||
FILE_LOG(logDEBUG1, ("Getting Threshold energy\n"));
|
||||
LOG(logDEBUG1, ("Getting Threshold energy\n"));
|
||||
return eiger_photonenergy;
|
||||
}
|
||||
|
||||
|
||||
int setThresholdEnergy(int ev) {
|
||||
FILE_LOG(logINFO, ("Setting threshold energy:%d\n",ev));
|
||||
LOG(logINFO, ("Setting threshold energy:%d\n",ev));
|
||||
if (ev >= 0)
|
||||
eiger_photonenergy = ev;
|
||||
return getThresholdEnergy();
|
||||
@ -962,7 +962,7 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
if (val < 0)
|
||||
return;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, (mV ? "mV" : "dac units")));
|
||||
LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, (mV ? "mV" : "dac units")));
|
||||
|
||||
if (ind == E_VTHRESHOLD) {
|
||||
setDAC(E_VCMP_LL, val, mV);
|
||||
@ -975,7 +975,7 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
|
||||
// validate index
|
||||
if (ind < 0 || ind >= NDAC) {
|
||||
FILE_LOG(logERROR, ("\tDac index %d is out of bounds (0 to %d)\n", ind, NDAC - 1));
|
||||
LOG(logERROR, ("\tDac index %d is out of bounds (0 to %d)\n", ind, NDAC - 1));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1013,24 +1013,24 @@ int getDAC(enum DACINDEX ind, int mV) {
|
||||
(ret[1]==ret[2])&&
|
||||
(ret[2]==ret[3]) &&
|
||||
(ret[3]==ret[4])) {
|
||||
FILE_LOG(logINFO, ("\tvthreshold match\n"));
|
||||
LOG(logINFO, ("\tvthreshold match\n"));
|
||||
return ret[0];
|
||||
} else {
|
||||
FILE_LOG(logERROR, ("\tvthreshold mismatch vcmp_ll:%d vcmp_lr:%d vcmp_rl:%d vcmp_rr:%d vcp:%d\n",
|
||||
LOG(logERROR, ("\tvthreshold mismatch vcmp_ll:%d vcmp_lr:%d vcmp_rl:%d vcmp_rr:%d vcp:%d\n",
|
||||
ret[0],ret[1],ret[2],ret[3], ret[4]));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mV) {
|
||||
FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac\n",ind, (detectorModules)->dacs[ind]));
|
||||
LOG(logDEBUG1, ("Getting DAC %d : %d dac\n",ind, (detectorModules)->dacs[ind]));
|
||||
return (detectorModules)->dacs[ind];
|
||||
}
|
||||
int voltage = -1;
|
||||
// dac units to voltage
|
||||
ConvertToDifferentRange(LTC2620_MIN_VAL, LTC2620_MAX_VAL, DAC_MIN_MV, DAC_MAX_MV,
|
||||
(detectorModules)->dacs[ind], &voltage);
|
||||
FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac (%d mV)\n",ind, (detectorModules)->dacs[ind], voltage));
|
||||
LOG(logDEBUG1, ("Getting DAC %d : %d dac (%d mV)\n",ind, (detectorModules)->dacs[ind], voltage));
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@ -1072,7 +1072,7 @@ int getADC(enum ADCINDEX ind) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("Temperature %s: %f°C\n", tempnames[ind], (double)retval/1000.00));
|
||||
LOG(logINFO, ("Temperature %s: %f°C\n", tempnames[ind], (double)retval/1000.00));
|
||||
|
||||
return retval;
|
||||
#endif
|
||||
@ -1106,13 +1106,13 @@ int setHighVoltage(int val) {
|
||||
|
||||
// get
|
||||
if (!Feb_Control_GetHighVoltage(&eiger_highvoltage)) {
|
||||
FILE_LOG(logERROR, ("Could not read high voltage\n"));
|
||||
LOG(logERROR, ("Could not read high voltage\n"));
|
||||
return -3;
|
||||
}
|
||||
|
||||
// tolerance of 5
|
||||
if (abs(eiger_theo_highvoltage-eiger_highvoltage) > HIGH_VOLTAGE_TOLERANCE) {
|
||||
FILE_LOG(logINFO, ("High voltage still ramping: %d\n", eiger_highvoltage));
|
||||
LOG(logINFO, ("High voltage still ramping: %d\n", eiger_highvoltage));
|
||||
return eiger_highvoltage;
|
||||
}
|
||||
return eiger_theo_highvoltage;
|
||||
@ -1146,10 +1146,10 @@ void setTiming( enum timingMode arg) {
|
||||
ret = 3;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
|
||||
LOG(logERROR, ("Unknown timing mode %d\n", arg));
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret));
|
||||
LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetTriggerMode(ret,1))
|
||||
#endif
|
||||
@ -1168,7 +1168,7 @@ enum timingMode getTiming() {
|
||||
case 3:
|
||||
return GATED;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown trigger mode found %d\n", eiger_triggermode));
|
||||
LOG(logERROR, ("Unknown trigger mode found %d\n", eiger_triggermode));
|
||||
return GET_TIMING_MODE;
|
||||
}
|
||||
}
|
||||
@ -1186,7 +1186,7 @@ int configureMAC() {
|
||||
int destport = udpDetails.dstport;
|
||||
int destport2 = udpDetails.dstport2;
|
||||
|
||||
FILE_LOG(logINFO, ("Configuring MAC\n"));
|
||||
LOG(logINFO, ("Configuring MAC\n"));
|
||||
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, sourcemac);
|
||||
@ -1194,7 +1194,7 @@ int configureMAC() {
|
||||
getIpAddressinString(src_ip, sourceip);
|
||||
getIpAddressinString(dst_ip, destip);
|
||||
|
||||
FILE_LOG(logINFO, (
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
@ -1209,13 +1209,13 @@ int configureMAC() {
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d, port2:%d)\n", cDestIp, destport, destport2));
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d, port2:%d)\n", cDestIp, destport, destport2));
|
||||
if (setUDPDestinationDetails(0, cDestIp, destport) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (setUDPDestinationDetails(1, cDestIp, destport2) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port2\n"));
|
||||
LOG(logERROR, ("could not set udp destination IP and port2\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
@ -1227,13 +1227,13 @@ int configureMAC() {
|
||||
if (!top)
|
||||
dst_port = destport2;
|
||||
|
||||
FILE_LOG(logINFO, ("\tDest Port : %d\n", dst_port));
|
||||
LOG(logINFO, ("\tDest Port : %d\n", dst_port));
|
||||
|
||||
int i=0;
|
||||
/* for(i=0;i<32;i++) { modified for Aldo*/
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
|
||||
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) {
|
||||
FILE_LOG(logDEBUG1, ("\tset up left ok\n"));
|
||||
LOG(logDEBUG1, ("\tset up left ok\n"));
|
||||
} else {
|
||||
return FAIL;
|
||||
}
|
||||
@ -1243,12 +1243,12 @@ int configureMAC() {
|
||||
dst_port = destport2;
|
||||
if (!top)
|
||||
dst_port = destport;
|
||||
FILE_LOG(logINFO, ("\tDest Port : %d\n",dst_port));
|
||||
LOG(logINFO, ("\tDest Port : %d\n",dst_port));
|
||||
|
||||
/*for(i=0;i<32;i++) {*//** modified for Aldo*/
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
|
||||
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) {
|
||||
FILE_LOG(logDEBUG1, (" set up right ok\n"));
|
||||
LOG(logDEBUG1, (" set up right ok\n"));
|
||||
} else {
|
||||
return FAIL;
|
||||
}
|
||||
@ -1344,7 +1344,7 @@ int getReadNLines() {
|
||||
|
||||
int enableTenGigabitEthernet(int val) {
|
||||
if (val!=-1) {
|
||||
FILE_LOG(logINFO, ("Setting 10Gbe: %d\n", (val > 0) ? 1 : 0));
|
||||
LOG(logINFO, ("Setting 10Gbe: %d\n", (val > 0) ? 1 : 0));
|
||||
if (val>0)
|
||||
send_to_ten_gig = 1;
|
||||
else
|
||||
@ -1359,11 +1359,11 @@ int enableTenGigabitEthernet(int val) {
|
||||
/* eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter */
|
||||
int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
if (ind != RUN_CLK) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index: %d\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index: %d\n", ind));
|
||||
return FAIL;
|
||||
}
|
||||
if (val >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting Read out Speed: %d\n", val));
|
||||
LOG(logINFO, ("Setting Read out Speed: %d\n", val));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetReadoutSpeed(val))
|
||||
#endif
|
||||
@ -1374,7 +1374,7 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
|
||||
int getClockDivider(enum CLKINDEX ind) {
|
||||
if (ind != RUN_CLK) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index: %d\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index: %d\n", ind));
|
||||
return FAIL;
|
||||
}
|
||||
return eiger_readoutspeed;
|
||||
@ -1382,7 +1382,7 @@ int getClockDivider(enum CLKINDEX ind) {
|
||||
|
||||
int setIODelay(int val) {
|
||||
if (val!=-1) {
|
||||
FILE_LOG(logDEBUG1, ("Setting IO Delay: %d\n",val));
|
||||
LOG(logDEBUG1, ("Setting IO Delay: %d\n",val));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetIDelays(Feb_Control_GetModuleNumber(),val))
|
||||
#endif
|
||||
@ -1394,7 +1394,7 @@ int setIODelay(int val) {
|
||||
|
||||
int setCounterBit(int val) {
|
||||
if (val!=-1) {
|
||||
FILE_LOG(logINFO, ("Setting Counter Bit: %d\n",val));
|
||||
LOG(logINFO, ("Setting Counter Bit: %d\n",val));
|
||||
#ifdef VIRTUAL
|
||||
eiger_virtual_counter_bit = val;
|
||||
#else
|
||||
@ -1458,10 +1458,10 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
|
||||
//same setting
|
||||
if ((tau_in_nsec == custom_tau_in_nsec) && (ratetable_period_in_nsec == actual_period)) {
|
||||
if (eiger_dynamicrange == 32) {
|
||||
FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n",
|
||||
LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n",
|
||||
(long long int)tau_in_nsec,(long long int)ratetable_period_in_nsec));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n",
|
||||
LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n",
|
||||
(long long int)tau_in_nsec,(long long int)ratetable_period_in_nsec));
|
||||
}
|
||||
}
|
||||
@ -1475,7 +1475,7 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
|
||||
}
|
||||
//activating rate correction
|
||||
eiger_virtual_ratecorrection_variable = 1;
|
||||
FILE_LOG(logINFO, ("Rate Correction Value set to %lld ns\n",(long long int)eiger_virtual_ratetable_tau_in_ns));
|
||||
LOG(logINFO, ("Rate Correction Value set to %lld ns\n",(long long int)eiger_virtual_ratetable_tau_in_ns));
|
||||
|
||||
return eiger_virtual_ratetable_tau_in_ns;
|
||||
#else
|
||||
@ -1504,10 +1504,10 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
|
||||
//same setting
|
||||
if ((tau_in_nsec == custom_tau_in_nsec) && (ratetable_period_in_nsec == actual_period)) {
|
||||
if (dr == 32) {
|
||||
FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n",
|
||||
LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n",
|
||||
tau_in_nsec,ratetable_period_in_nsec));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n",
|
||||
LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n",
|
||||
tau_in_nsec,ratetable_period_in_nsec));
|
||||
}
|
||||
}
|
||||
@ -1515,14 +1515,14 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
|
||||
else {
|
||||
int ret = Feb_Control_SetRateCorrectionTau(custom_tau_in_nsec);
|
||||
if (ret<=0) {
|
||||
FILE_LOG(logERROR, ("Rate correction failed. Deactivating rate correction\n"));
|
||||
LOG(logERROR, ("Rate correction failed. Deactivating rate correction\n"));
|
||||
Feb_Control_SetRateCorrectionVariable(0);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
//activating rate correction
|
||||
Feb_Control_SetRateCorrectionVariable(1);
|
||||
FILE_LOG(logINFO, ("Rate Correction Value set to %lld ns\n", (long long int)Feb_Control_Get_RateTable_Tau_in_nsec()));
|
||||
LOG(logINFO, ("Rate Correction Value set to %lld ns\n", (long long int)Feb_Control_Get_RateTable_Tau_in_nsec()));
|
||||
Feb_Control_PrintCorrectedValues();
|
||||
|
||||
return Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
@ -1543,7 +1543,7 @@ int getDefaultSettingsTau_in_nsec() {
|
||||
|
||||
void setDefaultSettingsTau_in_nsec(int t) {
|
||||
default_tau_from_file = t;
|
||||
FILE_LOG(logINFO, ("Default tau set to %d\n", default_tau_from_file));
|
||||
LOG(logINFO, ("Default tau set to %d\n", default_tau_from_file));
|
||||
}
|
||||
|
||||
int64_t getCurrentTau() {
|
||||
@ -1572,7 +1572,7 @@ void setExternalGating(int enable[]) {
|
||||
int setAllTrimbits(int val) {
|
||||
#ifndef VIRTUAL
|
||||
if (!Feb_Control_SaveAllTrimbitsTo(val)) {
|
||||
FILE_LOG(logERROR, ("Could not set all trimbits\n"));
|
||||
LOG(logERROR, ("Could not set all trimbits\n"));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
@ -1583,7 +1583,7 @@ int setAllTrimbits(int val) {
|
||||
}
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("All trimbits have been set to %d\n", val));
|
||||
LOG(logINFO, ("All trimbits have been set to %d\n", val));
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1599,7 +1599,7 @@ int getAllTrimbits() {
|
||||
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO, ("Value of all Trimbits: %d\n", value));
|
||||
LOG(logINFO, ("Value of all Trimbits: %d\n", value));
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -1711,7 +1711,7 @@ int setTransmissionDelayRight(int value) {
|
||||
|
||||
int prepareAcquisition() {
|
||||
#ifndef VIRTUAL
|
||||
FILE_LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit()));
|
||||
LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit()));
|
||||
Feb_Control_PrepareForAcquisition();
|
||||
#endif
|
||||
return OK;
|
||||
@ -1728,15 +1728,15 @@ int startStateMachine() {
|
||||
if(createUDPSocket(1) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
eiger_virtual_status = 1;
|
||||
eiger_virtual_stop = 0;
|
||||
if (pthread_create(&eiger_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
FILE_LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
eiger_virtual_status = 0;
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO ,("Virtual Acquisition started\n"));
|
||||
LOG(logINFO ,("Virtual Acquisition started\n"));
|
||||
return OK;
|
||||
#else
|
||||
|
||||
@ -1744,21 +1744,21 @@ int startStateMachine() {
|
||||
//get the DAQ toggle bit
|
||||
prev_flag = Feb_Control_AcquisitionStartedBit();
|
||||
|
||||
FILE_LOG(logINFO, ("Going to start acquisition\n"));
|
||||
LOG(logINFO, ("Going to start acquisition\n"));
|
||||
Feb_Control_StartAcquisition();
|
||||
|
||||
if (!eiger_storeinmem) {
|
||||
FILE_LOG(logINFO, ("requesting images right after start\n"));
|
||||
LOG(logINFO, ("requesting images right after start\n"));
|
||||
ret = startReadOut();
|
||||
}
|
||||
|
||||
//wait for acquisition start
|
||||
if (ret == OK) {
|
||||
if (!Feb_Control_WaitForStartedFlag(5000, prev_flag)) {
|
||||
FILE_LOG(logERROR, ("Acquisition did not FILE_LOG(logERROR ouble reading register\n"));
|
||||
LOG(logERROR, ("Acquisition did not LOG(logERROR ouble reading register\n"));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFOGREEN, ("Acquisition started\n"));
|
||||
LOG(logINFOGREEN, ("Acquisition started\n"));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -1779,7 +1779,7 @@ void* start_timer(void* arg) {
|
||||
int numPacketsPerFrame = (tgEnable ? 4 : 16) * dr;
|
||||
int npixelsx = 256 * 2 * bytesPerPixel;
|
||||
int databytes = 256 * 256 * 2 * bytesPerPixel;
|
||||
FILE_LOG(logINFO, (" dr:%f\n bytesperpixel:%d\n tgenable:%d\n datasize:%d\n packetsize:%d\n numpackes:%d\n npixelsx:%d\n databytes:%d\n",
|
||||
LOG(logINFO, (" dr:%f\n bytesperpixel:%d\n tgenable:%d\n datasize:%d\n packetsize:%d\n numpackes:%d\n npixelsx:%d\n databytes:%d\n",
|
||||
dr, bytesPerPixel, tgEnable, datasize, packetsize, numPacketsPerFrame, npixelsx, databytes));
|
||||
|
||||
|
||||
@ -1855,7 +1855,7 @@ void* start_timer(void* arg) {
|
||||
sendUDPPacket(1, packetData2, packetsize);
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
@ -1873,7 +1873,7 @@ void* start_timer(void* arg) {
|
||||
closeUDPSocket(1);
|
||||
|
||||
eiger_virtual_status = 0;
|
||||
FILE_LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
@ -1882,13 +1882,13 @@ void* start_timer(void* arg) {
|
||||
|
||||
|
||||
int stopStateMachine() {
|
||||
FILE_LOG(logINFORED, ("Going to stop acquisition\n"));
|
||||
LOG(logINFORED, ("Going to stop acquisition\n"));
|
||||
#ifdef VIRTUAL
|
||||
eiger_virtual_stop = 0;
|
||||
return OK;
|
||||
#else
|
||||
if ((Feb_Control_StopAcquisition() != STATUS_IDLE) || (!Beb_StopAcquisition()) ) {
|
||||
FILE_LOG(logERROR, ("failed to stop acquisition\n"));
|
||||
LOG(logERROR, ("failed to stop acquisition\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@ -1914,7 +1914,7 @@ int softwareTrigger() {
|
||||
|
||||
int startReadOut() {
|
||||
|
||||
FILE_LOG(logINFO, ("Requesting images...\n"));
|
||||
LOG(logINFO, ("Requesting images...\n"));
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#else
|
||||
@ -1945,10 +1945,10 @@ int startReadOut() {
|
||||
enum runStatus getRunStatus() {
|
||||
#ifdef VIRTUAL
|
||||
if (eiger_virtual_status == 0) {
|
||||
FILE_LOG(logINFO, ("Status: IDLE\n"));
|
||||
LOG(logINFO, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Status: RUNNING...\n"));
|
||||
LOG(logINFO, ("Status: RUNNING...\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
#else
|
||||
@ -1956,13 +1956,13 @@ enum runStatus getRunStatus() {
|
||||
int i = Feb_Control_AcquisitionInProgress();
|
||||
switch (i) {
|
||||
case STATUS_ERROR:
|
||||
FILE_LOG(logERROR, ("Status: ERROR reading status register\n"));
|
||||
LOG(logERROR, ("Status: ERROR reading status register\n"));
|
||||
return ERROR;
|
||||
case STATUS_IDLE:
|
||||
FILE_LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
default:
|
||||
FILE_LOG(logINFOBLUE, ("Status: RUNNING...\n"));
|
||||
LOG(logINFOBLUE, ("Status: RUNNING...\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
|
||||
@ -1978,22 +1978,22 @@ void readFrame(int *ret, char *mess) {
|
||||
while(eiger_virtual_status == 1){
|
||||
usleep(500);
|
||||
}
|
||||
FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||
LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||
return;
|
||||
#else
|
||||
|
||||
if (Feb_Control_WaitForFinishedFlag(5000) == STATUS_ERROR) {
|
||||
FILE_LOG(logERROR, ("Waiting for finished flag\n"));
|
||||
LOG(logERROR, ("Waiting for finished flag\n"));
|
||||
*ret = FAIL;
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logINFOGREEN, ("Acquisition finished\n"));
|
||||
LOG(logINFOGREEN, ("Acquisition finished\n"));
|
||||
|
||||
if (eiger_storeinmem) {
|
||||
FILE_LOG(logINFO, ("requesting images after storing in memory\n"));
|
||||
LOG(logINFO, ("requesting images after storing in memory\n"));
|
||||
if (startReadOut() == FAIL) {
|
||||
strcpy(mess,"Could not execute read image requests\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
*ret = (int)FAIL;
|
||||
return;
|
||||
}
|
||||
@ -2001,7 +2001,7 @@ void readFrame(int *ret, char *mess) {
|
||||
|
||||
//wait for detector to send
|
||||
Beb_EndofDataSend(send_to_ten_gig);
|
||||
FILE_LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
|
||||
LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2020,7 +2020,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
int idac, ichan;
|
||||
int ret=OK;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Copying module\n"));
|
||||
LOG(logDEBUG1, ("Copying module\n"));
|
||||
|
||||
if (srcMod->serialnumber>=0) {
|
||||
|
||||
@ -2028,16 +2028,16 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
}
|
||||
//no trimbit feature
|
||||
if (destMod->nchan && ((srcMod->nchan)>(destMod->nchan))) {
|
||||
FILE_LOG(logINFO, ("Number of channels of source is larger than number of channels of destination\n"));
|
||||
LOG(logINFO, ("Number of channels of source is larger than number of channels of destination\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if ((srcMod->ndac)>(destMod->ndac)) {
|
||||
FILE_LOG(logINFO, ("Number of dacs of source is larger than number of dacs of destination\n"));
|
||||
LOG(logINFO, ("Number of dacs of source is larger than number of dacs of destination\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1, ("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac));
|
||||
FILE_LOG(logDEBUG1, ("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan));
|
||||
LOG(logDEBUG1, ("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac));
|
||||
LOG(logDEBUG1, ("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan));
|
||||
destMod->ndac=srcMod->ndac;
|
||||
destMod->nchip=srcMod->nchip;
|
||||
destMod->nchan=srcMod->nchan;
|
||||
@ -2049,7 +2049,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
destMod->tau=srcMod->tau;
|
||||
if (srcMod->eV>=0)
|
||||
destMod->eV=srcMod->eV;
|
||||
FILE_LOG(logDEBUG1, ("Copying register %x (%x)\n",destMod->reg,srcMod->reg ));
|
||||
LOG(logDEBUG1, ("Copying register %x (%x)\n",destMod->reg,srcMod->reg ));
|
||||
|
||||
if (destMod->nchan!=0) {
|
||||
for (ichan=0; ichan<(srcMod->nchan); ichan++) {
|
||||
@ -2057,7 +2057,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
*((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan);
|
||||
}
|
||||
}
|
||||
else FILE_LOG(logINFO, ("Not Copying trimbits\n"));
|
||||
else LOG(logINFO, ("Not Copying trimbits\n"));
|
||||
|
||||
for (idac=0; idac<(srcMod->ndac); idac++) {
|
||||
if (*((srcMod->dacs)+idac)>=0) {
|
||||
|
Reference in New Issue
Block a user