moduleid for eiger m3 and g2, but set only for g2

This commit is contained in:
2021-09-01 17:06:34 +02:00
parent 25d03f949e
commit a51deda2a4
22 changed files with 180 additions and 95 deletions

View File

@ -1022,18 +1022,19 @@ int Beb_GetBebFPGATemp() {
return temperature;
}
void Beb_SetDetectorNumber(uint32_t detid) {
int Beb_SetModuleId(uint32_t detid) {
if (!Beb_activated)
return;
return OK;
uint32_t swapid = Beb_swap_uint16(detid);
// 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) {
LOG(logERROR, ("Set Detector ID FAIL\n"));
return;
LOG(logERROR, ("Set module id FAIL\n"));
return FAIL;
} else {
// left
uint32_t value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
value &= UDP_HEADER_X_MSK; // to keep previous x value
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST,
@ -1042,8 +1043,11 @@ void Beb_SetDetectorNumber(uint32_t detid) {
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
if ((value & UDP_HEADER_ID_MSK) !=
((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) {
LOG(logERROR, ("Set Detector ID FAIL\n"));
LOG(logERROR, ("Set module id FAIL\n"));
Beb_close(fd, csp0base);
return FAIL;
}
// right
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,
@ -1052,11 +1056,13 @@ void Beb_SetDetectorNumber(uint32_t detid) {
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
if ((value & UDP_HEADER_ID_MSK) !=
((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) {
LOG(logERROR, ("Set Detector ID FAIL\n"));
LOG(logERROR, ("Set module id FAIL\n"));
Beb_close(fd, csp0base);
return FAIL;
}
Beb_close(fd, csp0base);
}
LOG(logINFO, ("Detector id %d set in UDP Header\n\n", detid));
LOG(logINFO, ("Module id %d set in UDP Header\n\n", detid));
}
int Beb_SetQuad(int value) {

View File

@ -42,7 +42,7 @@ int Beb_StopAcquisition();
int Beb_RequestNImages(int ten_gig, unsigned int nimages,
int test_just_send_out_packets_no_wait);
int Beb_GetBebFPGATemp();
void Beb_SetDetectorNumber(uint32_t detid);
int Beb_SetModuleId(uint32_t detid);
int Beb_SetQuad(int value);
int Beb_GetQuad();
int *Beb_GetDetectorPosition();

View File

@ -100,3 +100,4 @@ install(TARGETS eigerDetectorServerSlaveBottom_virtual
configure_file(config_eiger.txt ${CMAKE_BINARY_DIR}/bin/config_eiger.txt COPYONLY)
configure_file(detid_eiger.txt ${CMAKE_BINARY_DIR}/bin/detid_eiger.txt COPYONLY)

View File

@ -34,6 +34,7 @@ $(PROGS): $(OBJS)
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
mv $(PROGS) $(DESTDIR)
cp config_eiger.txt $(DESTDIR)
cp detid.txt $(DESTDIR)
hv9m_blackfin_server:9mhvserial_bf.c

View File

@ -46,9 +46,6 @@ unsigned int nimages_per_request = 1;
int top = 0;
int master = 0;
int normal = 0;
#ifndef VIRTUAL
uint32_t detid = 0;
#endif
int eiger_highvoltage = 0;
int eiger_theo_highvoltage = 0;
@ -222,25 +219,8 @@ u_int64_t getFirmwareAPIVersion() {
#endif
}
void readDetectorNumber() {
#ifndef VIRTUAL
char output[255];
FILE *sysFile = popen(IDFILECOMMAND, "r");
fgets(output, sizeof(output), sysFile);
pclose(sysFile);
sscanf(output, "%u", &detid);
if (isControlServer) {
LOG(logINFOBLUE, ("Detector ID: %u\n", detid));
}
#endif
}
u_int32_t getDetectorNumber() {
#ifdef VIRTUAL
return 0;
#else
return detid;
#endif
int getModuleId(int *ret, char *mess) {
return getModuleIdInFile(ret, mess, ID_FILE);
}
u_int64_t getDetectorMAC() {
@ -322,7 +302,14 @@ u_int32_t getDetectorIP() {
void initControlServer() {
LOG(logINFOBLUE, ("Configuring Control server\n"));
if (!updateFlag && initError == OK) {
readDetectorNumber();
#ifndef VIRTUAL
int detid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
#else
getModuleIdInFile(&initError, initErrorMessage, ID_FILE);
#endif
if (initError == FAIL) {
return;
}
getModuleConfiguration();
#ifndef VIRTUAL
sharedMemory_lockLocalLink();
@ -355,7 +342,7 @@ void initControlServer() {
LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
Beb_SetTopVariable(top);
Beb_Beb();
Beb_SetDetectorNumber(getDetectorNumber());
Beb_SetModuleId(detid);
LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
#endif
// also reads config file and deactivates

View File

@ -2,7 +2,11 @@
#include "sls/sls_detector_defs.h"
#define REQUIRED_FIRMWARE_VERSION (27)
#define IDFILECOMMAND "more /home/root/executables/detid.txt"
#ifdef VIRTUAL
#define ID_FILE "detid_eiger.txt"
#else
#define ID_FILE "detid.txt"
#endif
#define CONFIG_FILE ("config_eiger.txt")
#define WAIT_STOP_SERVER_START (1 * 1000 * 1000)