gotthard2: first edit

This commit is contained in:
2020-01-20 12:13:23 +01:00
parent 6e47f0b7f7
commit 6cfd0f8962
17 changed files with 322 additions and 53 deletions

View File

@ -19,6 +19,8 @@ extern int ret;
// Global variables from slsDetectorServer_funcs
extern int sockfd;
extern int debugflag;
extern int checkModuleFlag;
// Global variables from slsDetectorFunctionList
#ifdef GOTTHARDD
@ -67,7 +69,11 @@ int main(int argc, char *argv[]){
FILE_LOG(logINFO, ("Detected developer mode\n"));
debugflag = 1;
}
else if(!strcasecmp(argv[i],"--port")){
else if(!strcasecmp(argv[i],"-nomodule")){
FILE_LOG(logINFO, ("Detected No Module mode\n"));
checkModuleFlag = 0;
}
else if(!strcasecmp(argv[i],"-port")){
if ((i + 1) >= argc) {
FILE_LOG(logERROR, ("no port value given. Exiting.\n"));
return -1;
@ -105,7 +111,7 @@ int main(int argc, char *argv[]){
int i;
for (i = 0; i < argc; ++i)
sprintf(cmd, "%s %s", cmd, argv[i]);
sprintf(cmd,"%s -stopserver --port %d &", cmd, portno + 1);
sprintf(cmd,"%s -stopserver -port %d &", cmd, portno + 1);
FILE_LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
system(cmd);
}

View File

@ -39,6 +39,7 @@ extern char mess[MAX_STR_LENGTH];
// Variables that will be exported
int sockfd = 0;
int debugflag = 0;
int checkModuleFlag = 1;
udpStruct udpDetails = {32410, 32411, 50001, 50002, 0, 0, 0, 0, 0, 0, 0, 0};
int configured = FAIL;
char configureMessage[MAX_STR_LENGTH]="udp parameters not configured yet";
@ -307,6 +308,8 @@ const char* getFunctionName(enum detFuncs func) {
case F_GET_ADC_ENABLE_MASK_10G: return "F_GET_ADC_ENABLE_MASK_10G";
case F_SET_COUNTER_MASK: return "F_SET_COUNTER_MASK";
case F_GET_COUNTER_MASK: return "F_GET_COUNTER_MASK";
case F_SET_BURST_TYPE: return "F_SET_BURST_TYPE";
case F_GET_BURST_TYPE: return "F_GET_BURST_TYPE";
default: return "Unknown Function";
}
@ -491,6 +494,8 @@ void function_table() {
flist[F_GET_ADC_ENABLE_MASK_10G] = &get_adc_enable_mask_10g;
flist[F_SET_COUNTER_MASK] = &set_counter_mask;
flist[F_GET_COUNTER_MASK] = &get_counter_mask;
flist[F_SET_BURST_TYPE] = &set_burst_type;
flist[F_GET_BURST_TYPE] = &get_burst_type;
// check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -3843,19 +3848,23 @@ int power_chip(int file_des) {
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
// check only when powering on
if (arg != -1 && arg != 0) {
int type_ret = checkDetectorType();
if (type_ret == -1) {
ret = FAIL;
sprintf(mess, "Could not power on chip. Could not open file to get type of module attached.\n");
FILE_LOG(logERROR,(mess));
} else if (type_ret == -2) {
ret = FAIL;
sprintf(mess, "Could not power on chip. No module attached!\n");
FILE_LOG(logERROR,(mess));
} else if (type_ret == FAIL) {
ret = FAIL;
sprintf(mess, "Could not power on chip. Wrong module attached!\n");
FILE_LOG(logERROR,(mess));
if (checkModuleFlag) {
int type_ret = checkDetectorType();
if (type_ret == -1) {
ret = FAIL;
sprintf(mess, "Could not power on chip. Could not open file to get type of module attached.\n");
FILE_LOG(logERROR,(mess));
} else if (type_ret == -2) {
ret = FAIL;
sprintf(mess, "Could not power on chip. No module attached!\n");
FILE_LOG(logERROR,(mess));
} else if (type_ret == FAIL) {
ret = FAIL;
sprintf(mess, "Could not power on chip. Wrong module attached!\n");
FILE_LOG(logERROR,(mess));
}
} else {
FILE_LOG(logINFOBLUE, ("In No-Module mode: Ignoring module type. Continuing.\n"));
}
}
#endif
@ -6579,4 +6588,61 @@ int get_counter_mask(int file_des) {
FILE_LOG(logDEBUG, ("counter mask retval: 0x%x\n", retval));
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}
int set_burst_type(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum burstModeType arg = 0;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
FILE_LOG(logINFO, ("Setting burst type: %d\n", arg));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
switch (arg) {
case INTERNAL:
case EXTERNAL:
break;
default:
modeNotImplemented("Burst type", (int)arg);
break;
}
if (ret == OK) {
setBurstType(arg);
enum burstModeType retval = getBurstType();
FILE_LOG(logDEBUG, ("burst type retval: %d\n", retval));
if (retval != arg) {
ret = FAIL;
sprintf(mess, "Could not set burst type. Set %s, got %s\n", (arg == 0 ? "internal" : "external"), (retval == 0 ? "internal" : "external"));
FILE_LOG(logERROR, (mess));
}
}
}
#endif
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
}
int get_burst_type(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
enum burstModeType retval = 0;
FILE_LOG(logDEBUG1, ("Getting burst type\n"));
#ifndef GOTTHARD2D
functionNotImplemented();
#else
// get only
retval = getBurstType();
FILE_LOG(logDEBUG, ("burst type retval: %d\n", retval));
#endif
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
}