diff --git a/slsDetectorSoftware/eigerDetectorServer/FebControl.c b/slsDetectorSoftware/eigerDetectorServer/FebControl.c index ce68ef7ce..76028a105 100644 --- a/slsDetectorSoftware/eigerDetectorServer/FebControl.c +++ b/slsDetectorSoftware/eigerDetectorServer/FebControl.c @@ -1921,4 +1921,35 @@ int Feb_Control_GetRightFPGATemp(){ } +uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data) { + uint32_t value=0; + if(Module_TopAddressIsValid(&modules[1])){ + if(!Feb_Interface_WriteRegister(Module_GetTopRightAddress (&modules[1]),offset, data,0, 0)) { + cprintf(RED,"Could not read value. Value read:%d\n", value); + value = 0; + } + } else { + if(!Feb_Interface_WriteRegister(Module_GetBottomRightAddress (&modules[1]),offset, data,0, 0)) { + cprintf(RED,"Could not read value. Value read:%d\n", value); + value = 0; + } + } + return Feb_Control_ReadRegister(offset); +} + +uint32_t Feb_Control_ReadRegister(uint32_t offset) { + uint32_t value=0; + if(Module_TopAddressIsValid(&modules[1])){ + if(!Feb_Interface_ReadRegister(Module_GetTopRightAddress (&modules[1]),offset, &value)) { + cprintf(RED,"Could not read value. Value read:%d\n", value); + value = 0; + } + } else { + if(!Feb_Interface_ReadRegister(Module_GetBottomRightAddress (&modules[1]),offset, &value)) { + cprintf(RED,"Could not read value. Value read:%d\n", value); + value = 0; + } + } + return value; +} diff --git a/slsDetectorSoftware/eigerDetectorServer/FebControl.h b/slsDetectorSoftware/eigerDetectorServer/FebControl.h index fb75c8a67..892d6b22c 100644 --- a/slsDetectorSoftware/eigerDetectorServer/FebControl.h +++ b/slsDetectorSoftware/eigerDetectorServer/FebControl.h @@ -198,4 +198,6 @@ int Feb_Control_GetModuleNumber(); int Feb_Control_GetLeftFPGATemp(); int Feb_Control_GetRightFPGATemp(); + uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data); + uint32_t Feb_Control_ReadRegister(uint32_t offset); #endif diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.5 b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.6 similarity index 62% rename from slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.5 rename to slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.6 index 19f1ac075..1d201568e 100755 Binary files a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.5 and b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv3.0.0.16.6 differ diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c index 2bfa2ae5e..9ab1467ab 100644 --- a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c @@ -342,7 +342,14 @@ void setupDetector() { +/* advanced read/write reg */ +uint32_t writeRegister(uint32_t offset, uint32_t data) { + return Feb_Control_WriteRegister(offset, data); +} +uint32_t readRegister(uint32_t offset) { + return Feb_Control_ReadRegister(offset); +} /* set parameters - nmod, dr, roi */ diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index 12bb191fe..d33e5e4dd 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -3359,9 +3359,9 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) { return string("unknown detector size ")+cmd; if (cmd=="roimask") - sprintf(ans,"%x",ret); + sprintf(ans,"0x%x",ret); else - sprintf(ans,"%d",ret); + sprintf(ans,"0x%d",ret); return string(ans); @@ -3689,7 +3689,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) { if (cmd=="bustest"){ if (action==PUT_ACTION) return string("cannot set ")+cmd; - sprintf(answer,"%x",myDet->digitalTest(DETECTOR_BUS_TEST)); + sprintf(answer,"0x%x",myDet->digitalTest(DETECTOR_BUS_TEST)); return string(answer); } @@ -3698,7 +3698,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) { return string("cannot set ")+cmd; int ival=-1; if (sscanf(args[0],"digitest:%d",&ival)) { - sprintf(answer,"%x",myDet->digitalTest(CHIP_TEST, ival)); + sprintf(answer,"0x%x",myDet->digitalTest(CHIP_TEST, ival)); return string(answer); } else return string("undefined module number"); @@ -3710,7 +3710,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action) { int ival=-1; if (sscanf(args[1],"%d",&ival)) { if((ival==0)||(ival==1)){ - sprintf(answer,"%x",myDet->digitalTest(DIGITAL_BIT_TEST,ival)); + sprintf(answer,"0x%x",myDet->digitalTest(DIGITAL_BIT_TEST,ival)); return string(answer); } else @@ -3783,13 +3783,13 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) { ; else return string("Could not scan value (hexadecimal fomat) ")+string(args[2]); - sprintf(answer,"%x",myDet->writeRegister(addr,val)); + sprintf(answer,"0x%x",myDet->writeRegister(addr,val)); } else if (cmd=="adcreg") { if (sscanf(args[2],"%x",&val)) ; else return string("Could not scan value (hexadecimal fomat) ")+string(args[2]); - sprintf(answer,"%x",myDet->writeAdcRegister(addr,val)); + sprintf(answer,"0x%x",myDet->writeAdcRegister(addr,val)); } else { if (sscanf(args[2],"%d",&n)) @@ -3801,9 +3801,9 @@ string slsDetectorCommand::cmdRegister(int narg, char *args[], int action) { return string("Bit number out of range")+string(args[2]); if (cmd=="setbit") - sprintf(answer,"%x",myDet->writeRegister(addr,myDet->readRegister(addr)| 1<writeRegister(addr,myDet->readRegister(addr)| 1<writeRegister(addr,myDet->readRegister(addr) & ~(1<writeRegister(addr,myDet->readRegister(addr) & ~(1<readRegister(addr)); + sprintf(answer,"0x%x",myDet->readRegister(addr)); } @@ -3861,7 +3861,7 @@ string slsDetectorCommand::helpRegister(int narg, char *args[], int action) { ostringstream os; if (action==PUT_ACTION || action==HELP_ACTION) { - os << "reg addr val \n writes the register addr with the value val"<< std::endl; + os << "reg addr val \n writes the register addr with the value val (hexadecimal format)"<< std::endl; } if (action==GET_ACTION || action==HELP_ACTION) { os << "reg addr \n reads the register addr"<< std::endl; diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h index 14a08a07d..145af32fa 100644 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h @@ -59,6 +59,9 @@ void setupDetector(); #ifndef EIGERD extern u_int32_t writeRegister(u_int32_t offset, u_int32_t data); // blackfin.h extern u_int32_t readRegister(u_int32_t offset); // blackfin.h +#else +uint32_t writeRegister(uint32_t offset, uint32_t data); +uint32_t readRegister(uint32_t offset); #endif diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c index 8caad22fe..7e7ef4e65 100755 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c @@ -1242,15 +1242,6 @@ int write_register(int file_des) { int retval=-1; sprintf(mess,"write to register failed\n"); -#ifdef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Write Register) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - // receive arguments int arg[2]={-1,-1}; n = receiveData(file_des,arg,sizeof(arg),INT32); @@ -1282,7 +1273,6 @@ int write_register(int file_des) { #endif if (ret==OK && differentClients) ret=FORCE_UPDATE; -#endif // ret could be swapped during sendData ret1 = ret; @@ -1310,15 +1300,6 @@ int read_register(int file_des) { int retval=-1; sprintf(mess,"read register failed\n"); -#ifdef EIGERD - //to receive any arguments - while (n > 0) - n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); - ret = FAIL; - sprintf(mess,"Function (Read Register) is not implemented for this detector\n"); - cprintf(RED, "Warning: %s", mess); -#else - // receive arguments int arg=0; n = receiveData(file_des,&arg,sizeof(arg),INT32); @@ -1337,7 +1318,6 @@ int read_register(int file_des) { #endif if (ret==OK && differentClients) ret=FORCE_UPDATE; -#endif // ret could be swapped during sendData ret1 = ret;