mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
gotthard works, data to be authenticated when personnel available
This commit is contained in:
@ -114,6 +114,25 @@ u_int32_t writeRegister(u_int32_t offset, u_int32_t data) {
|
||||
return readRegister(offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a 16 bit register (literal register value provided by client)
|
||||
* @param offset address offset
|
||||
* @retuns 16 bit data read
|
||||
*/
|
||||
u_int32_t readRegister16(u_int32_t offset) {
|
||||
return (u_int32_t)bus_r16(offset << MEM_MAP_SHIFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write into a 16 bit register (literal register value provided by client)
|
||||
* @param offset address offset
|
||||
* @param data 16 bit data
|
||||
*/
|
||||
u_int32_t writeRegister16(u_int32_t offset, u_int32_t data) {
|
||||
bus_w16(offset << MEM_MAP_SHIFT, (u_int16_t)data);
|
||||
return readRegister16(offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Map FPGA
|
||||
|
@ -132,7 +132,7 @@ int acceptConnection(int socketDescriptor) {
|
||||
|
||||
// timeout
|
||||
if (result == 0) {
|
||||
FILE_LOG(logDEBUG1, ("%s socket select() timed out!\n",
|
||||
FILE_LOG(logDEBUG3, ("%s socket select() timed out!\n",
|
||||
(isControlServer ? "control":"stop"), myport));
|
||||
}
|
||||
|
||||
@ -144,14 +144,14 @@ int acceptConnection(int socketDescriptor) {
|
||||
|
||||
// activity in descriptor set
|
||||
else if (result > 0) {
|
||||
FILE_LOG(logDEBUG1, ("%s select returned!\n", (isControlServer ? "control":"stop")));
|
||||
FILE_LOG(logDEBUG3, ("%s select returned!\n", (isControlServer ? "control":"stop")));
|
||||
|
||||
// loop through the file descriptor set
|
||||
for (j = 0; j < maxfd + 1; ++j) {
|
||||
|
||||
// checks if file descriptor part of set
|
||||
if (FD_ISSET(j, &tempset)) {
|
||||
FILE_LOG(logDEBUG1, ("fd %d is set\n",j));
|
||||
FILE_LOG(logDEBUG3, ("fd %d is set\n",j));
|
||||
|
||||
// clear the temporary set
|
||||
FD_CLR(j, &tempset);
|
||||
@ -212,7 +212,7 @@ int acceptConnection(int socketDescriptor) {
|
||||
// accept success
|
||||
else {
|
||||
inet_ntop(AF_INET, &(addressC.sin_addr), dummyClientIP, INET_ADDRSTRLEN);
|
||||
FILE_LOG(logDEBUG1, ("%s socket accepted connection, fd= %d\n",
|
||||
FILE_LOG(logDEBUG3, ("%s socket accepted connection, fd= %d\n",
|
||||
(isControlServer ? "control":"stop"), file_des));
|
||||
// add the file descriptor from accept
|
||||
FD_SET(file_des, &readset);
|
||||
@ -240,7 +240,7 @@ void closeConnection(int file_des) {
|
||||
void exitServer(int socketDescriptor) {
|
||||
if (socketDescriptor >= 0)
|
||||
close(socketDescriptor);
|
||||
FILE_LOG(logDEBUG1, ("Closing %s server\n", (isControlServer ? "control":"stop")));
|
||||
FILE_LOG(logDEBUG3, ("Closing %s server\n", (isControlServer ? "control":"stop")));
|
||||
FD_CLR(socketDescriptor, &readset);
|
||||
isock--;
|
||||
}
|
||||
@ -316,7 +316,7 @@ int receiveDataOnly(int file_des, void* buf,int length) {
|
||||
int nreceiving;
|
||||
int nreceived;
|
||||
if (file_des<0) return -1;
|
||||
FILE_LOG(logDEBUG1, ("want to receive %d Bytes to %s server\n",
|
||||
FILE_LOG(logDEBUG3, ("want to receive %d Bytes to %s server\n",
|
||||
length, (isControlServer ? "control":"stop")));
|
||||
|
||||
while(length > 0) {
|
||||
@ -335,8 +335,9 @@ int receiveDataOnly(int file_des, void* buf,int length) {
|
||||
if (total_received>0)
|
||||
strcpy(thisClientIP,dummyClientIP);
|
||||
|
||||
if (strcmp(lastClientIP,thisClientIP))
|
||||
if (strcmp(lastClientIP,thisClientIP)) {
|
||||
differentClients = 1;
|
||||
}
|
||||
else
|
||||
differentClients = 0;
|
||||
|
||||
@ -379,7 +380,7 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
|
||||
|
||||
int receiveModule(int file_des, sls_detector_module* myMod) {
|
||||
TLogLevel level = logDEBUG1;
|
||||
enum TLogLevel level = logDEBUG1;
|
||||
FILE_LOG(level, ("Receiving Module\n"));
|
||||
int ts = 0, n = 0;
|
||||
int nDacs = myMod->ndac;
|
||||
@ -454,7 +455,7 @@ int Server_VerifyLock() {
|
||||
int Server_SendResult(int fileDes, intType itype, int update, void* retval, int retvalSize) {
|
||||
|
||||
// update if different clients (ret can be ok or acquisition finished), not fail to not overwrite e message
|
||||
if (update && ret != FAIL && differentClients)
|
||||
if (update && isControlServer && ret != FAIL && differentClients)
|
||||
ret = FORCE_UPDATE;
|
||||
|
||||
// send success of operation
|
||||
|
@ -19,10 +19,10 @@
|
||||
#define FILELOG_MAX_LEVEL logINFO
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
enum TLogLevel{
|
||||
logERROR, logWARNING, logINFOBLUE, logINFOGREEN, logINFORED, logINFO,
|
||||
logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5
|
||||
}TLogLevel;
|
||||
};
|
||||
|
||||
#define ERROR_MSG_LENGTH 1000
|
||||
|
||||
@ -30,7 +30,7 @@ logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5
|
||||
if (lvl > FILELOG_MAX_LEVEL); \
|
||||
else {char* temp = FILELOG_BuildLog fmt; FILELOG_PrintLog(lvl, temp);free(temp);}
|
||||
|
||||
static inline void FILELOG_PrintLog(TLogLevel level, char* m) {
|
||||
static inline void FILELOG_PrintLog(enum TLogLevel level, char* m) {
|
||||
switch(level) {
|
||||
case logERROR: cprintf(RED BOLD, "ERROR: %s", m); break;
|
||||
case logWARNING: cprintf(YELLOW BOLD, "WARNING: %s", m); break;
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "sls_detector_defs.h"
|
||||
#include "slsDetectorServer_defs.h" // DAC_INDEX, ADC_INDEX, also include RegisterDefs.h
|
||||
|
||||
#ifdef GOTTHARDD
|
||||
#include "logger.h" // runState(enum TLogLevel)
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h> // FILE
|
||||
|
||||
@ -89,6 +91,7 @@ void configureASICTimer();
|
||||
#elif GOTTHARDD
|
||||
void setPhaseShiftOnce();
|
||||
void setPhaseShift(int numphaseshift);
|
||||
void configureADC();
|
||||
void cleanFifos();
|
||||
void setADCSyncRegister();
|
||||
void setDAQRegister();
|
||||
@ -119,7 +122,9 @@ int selectStoragecellStart(int pos);
|
||||
#endif
|
||||
int64_t setTimer(enum timerIndex ind, int64_t val);
|
||||
int64_t getTimeLeft(enum timerIndex ind);
|
||||
|
||||
#if defined(JUNGFRAUD) || (GOTTHARDD)
|
||||
int validateTimer(enum timerIndex ind, int64_t val, int64_t retval);
|
||||
#endif
|
||||
|
||||
// parameters - module, settings
|
||||
int setModule(sls_detector_module myMod, char* mess);
|
||||
@ -250,7 +255,7 @@ void readFrame(int *ret, char *mess);
|
||||
u_int32_t runBusy();
|
||||
#endif
|
||||
#ifdef GOTTHARDD
|
||||
u_int32_t runState();
|
||||
u_int32_t runState(enum TLogLevel lev);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -104,8 +104,8 @@ int decode_function(int file_des) {
|
||||
if (ret == FAIL) {
|
||||
FILE_LOG(logDEBUG1, ("Error executing the function = %d (%s)\n",
|
||||
fnum, getFunctionName((enum detFuncs)fnum)));
|
||||
} else FILE_LOG(logDEBUG1, ("Function (%s) executed ok\n",
|
||||
getFunctionName((enum detFuncs)fnum)));
|
||||
} else FILE_LOG(logDEBUG1, ("Function (%s) executed %s\n",
|
||||
getFunctionName((enum detFuncs)fnum), (ret == OK)?"OK":"FORCE_UPDATE"));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -366,7 +366,7 @@ int get_detector_type(int file_des) {
|
||||
memset(mess, 0, sizeof(mess));
|
||||
enum detectorType retval = myDetectorType;
|
||||
FILE_LOG(logDEBUG1,("Returning detector type %d\n", retval));
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
return Server_SendResult(file_des, INT32, NO_UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
@ -849,7 +849,7 @@ int read_register(int file_des) {
|
||||
#else
|
||||
retval = readRegister(addr);
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1, ("Read register (0x%x): 0x%x\n", retval));
|
||||
FILE_LOG(logINFO, ("Read register (0x%x): 0x%x\n", addr, retval));
|
||||
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
@ -1308,8 +1308,34 @@ int set_timer(int file_des) {
|
||||
modeNotImplemented("Timer index", (int)ind);
|
||||
break;
|
||||
}
|
||||
|
||||
// validate
|
||||
validate64(tns, retval, "set timer", DEC);
|
||||
#ifdef EIGERD
|
||||
validate64(tns, retval, "set timer", DEC); // copied to server, not read from detector register
|
||||
#else
|
||||
switch(ind) {
|
||||
case FRAME_NUMBER:
|
||||
case CYCLES_NUMBER:
|
||||
case STORAGE_CELL_NUMBER:
|
||||
validate64(tns, retval, "set timer", DEC); // no conversion, so all good
|
||||
break;
|
||||
case ACQUISITION_TIME:
|
||||
case FRAME_PERIOD:
|
||||
case DELAY_AFTER_TRIGGER:
|
||||
case SUBFRAME_ACQUISITION_TIME:
|
||||
case SUBFRAME_DEADTIME:
|
||||
// losing precision due to conversion to clock (also gotthard master delay is different)
|
||||
if (validateTimer(ind, tns, retval) == FAIL) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set timer. Set %lld, but read %lld\n",
|
||||
(long long unsigned int)tns, (long long unsigned int)retval);
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (ret != FAIL) {
|
||||
FILE_LOG(logDEBUG1, ("Timer index %d: %lld\n", ind, retval));
|
||||
@ -1608,7 +1634,7 @@ int set_speed(int file_des) {
|
||||
|
||||
|
||||
int exit_server(int file_des) {
|
||||
cprintf(BG_RED, "Closing Server\n");
|
||||
FILE_LOG(logINFORED, ("Closing Server\n"));
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0);
|
||||
@ -1791,7 +1817,7 @@ int configure_mac(int file_des) {
|
||||
|
||||
if (receiveData(file_des, args, sizeof(args), OTHER) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logDEBUG1, ("\n Configuring UDP Destination\n"));
|
||||
FILE_LOG(logDEBUG1, ("\n Configuring MAC\n"));
|
||||
uint32_t dstIp = 0;
|
||||
sscanf(args[0], "%x", &dstIp);
|
||||
FILE_LOG(logDEBUG1, ("Dst Ip Addr: %d.%d.%d.%d = 0x%x \n",
|
||||
@ -1890,10 +1916,11 @@ int configure_mac(int file_des) {
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess,"Configure Mac failed\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("\tConfigure MAC successful\n"));
|
||||
}
|
||||
#if defined(EIGERD) || defined (JUNGFRAUD)
|
||||
else {
|
||||
FILE_LOG(logINFO, ("Configure MAC successful: %d\n", ret));
|
||||
if (ret != FAIL) {
|
||||
ret = setDetectorPosition(pos);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set detector position\n");
|
||||
@ -2463,7 +2490,7 @@ int program_fpga(int file_des) {
|
||||
|
||||
|
||||
if (ret == FAIL) {
|
||||
cprintf(RED,"Failure: Breaking out of program receiving\n");
|
||||
FILE_LOG(logERROR, ("Failure: Breaking out of program receiving\n"));
|
||||
} else {
|
||||
//print progress
|
||||
FILE_LOG(logINFO, ("Writing to Flash:%d%%\r",
|
||||
@ -2787,7 +2814,7 @@ int check_version(int file_des) {
|
||||
}
|
||||
|
||||
if (ret == OK) {
|
||||
FILE_LOG(logDEBUG1, ("Checking versioning compatibility with value %d\n",arg));
|
||||
FILE_LOG(logDEBUG1, ("Checking versioning compatibility with value 0x%llx\n",arg));
|
||||
|
||||
int64_t client_requiredVersion = arg;
|
||||
int64_t det_apiVersion = getDetectorId(CLIENT_SOFTWARE_API_VERSION);
|
||||
@ -2813,7 +2840,7 @@ int check_version(int file_des) {
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
}
|
||||
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
|
||||
return Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user