conflict resolved, changed to using hex() instead of str() in configuremac

This commit is contained in:
maliakal_d 2019-04-03 14:11:01 +02:00
commit bbfb5df30d
30 changed files with 711 additions and 507 deletions

1
.gitignore vendored
View File

@ -7,6 +7,7 @@ bin/
*.out *.out
*.toc *.toc
*.o *.o
.*
build build
docs/ docs/
RELEASE.txt RELEASE.txt

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/ctbDetectorServer Path: slsDetectorPackage/slsDetectorServers/ctbDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 5a4122ae7c8dae1572e9db336de70183956e58c7 Repsitory UUID: 45b837b42a9f190cb68688fd2b1a8d77c3050578
Revision: 50 Revision: 52
Branch: refactor Branch: program2
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4481 Last Changed Rev: 4490
Last Changed Date: 2019-03-28 08:18:03.000000002 +0100 ../slsDetectorServer/slsDetectorFunctionList.h Last Changed Date: 2019-04-02 17:21:25.000000002 +0200 ./slsDetectorServer_defs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "5a4122ae7c8dae1572e9db336de70183956e58c7" #define GITREPUUID "45b837b42a9f190cb68688fd2b1a8d77c3050578"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4481 #define GITREV 0x4490
#define GITDATE 0x20190328 #define GITDATE 0x20190402
#define GITBRANCH "refactor" #define GITBRANCH "program2"

View File

@ -3,11 +3,9 @@
#include "RegisterDefs.h" #include "RegisterDefs.h"
#define GOODBYE (-200)
#define MIN_REQRD_VRSN_T_RD_API 0x181130 #define MIN_REQRD_VRSN_T_RD_API 0x181130
#define REQRD_FRMWR_VRSN 0x190310 #define REQRD_FRMWR_VRSN 0x190310
#define PROGRAMMING_MODE (0x2)
#define CTRL_SRVR_INIT_TIME_US (1 * 1000 * 1000) #define CTRL_SRVR_INIT_TIME_US (1 * 1000 * 1000)
/* Struct Definitions */ /* Struct Definitions */

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/eigerDetectorServer Path: slsDetectorPackage/slsDetectorServers/eigerDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: c7ad548e4c2026a826b9f269f32d9970ce0a44e8 Repsitory UUID: 45b837b42a9f190cb68688fd2b1a8d77c3050578
Revision: 31 Revision: 33
Branch: refactor Branch: program2
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4478 Last Changed Rev: 4490
Last Changed Date: 2019-03-27 08:46:12.000000002 +0100 ./Beb.c Last Changed Date: 2019-04-02 14:46:09.000000002 +0200 ../slsDetectorServer/slsDetectorServer_funcs.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "c7ad548e4c2026a826b9f269f32d9970ce0a44e8" #define GITREPUUID "45b837b42a9f190cb68688fd2b1a8d77c3050578"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4478 #define GITREV 0x4490
#define GITDATE 0x20190327 #define GITDATE 0x20190402
#define GITBRANCH "refactor" #define GITBRANCH "program2"

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#define GOODBYE (-200)
#define REQUIRED_FIRMWARE_VERSION (22) #define REQUIRED_FIRMWARE_VERSION (22)
#define IDFILECOMMAND "more /home/root/executables/detid.txt" #define IDFILECOMMAND "more /home/root/executables/detid.txt"

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/gotthardDetectorServer Path: slsDetectorPackage/slsDetectorServers/gotthardDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: cd5aea895b07b7af25e3fb74a341a861f9aa291c Repsitory UUID: 45b837b42a9f190cb68688fd2b1a8d77c3050578
Revision: 26 Revision: 28
Branch: jungfrau Branch: program2
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4473 Last Changed Rev: 4490
Last Changed Date: 2019-03-22 17:13:44.000000002 +0100 ../slsDetectorServer/slsDetectorServer_funcs.c Last Changed Date: 2019-04-02 17:21:48.000000002 +0200 ./slsDetectorServer_defs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "cd5aea895b07b7af25e3fb74a341a861f9aa291c" #define GITREPUUID "45b837b42a9f190cb68688fd2b1a8d77c3050578"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4473 #define GITREV 0x4490
#define GITDATE 0x20190322 #define GITDATE 0x20190402
#define GITBRANCH "jungfrau" #define GITBRANCH "program2"

View File

@ -2,8 +2,6 @@
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include <stdlib.h> #include <stdlib.h>
#define GOODBYE (-200)
/* Enums */ /* Enums */
enum ADCINDEX {TEMP_FPGA, TEMP_ADC}; enum ADCINDEX {TEMP_FPGA, TEMP_ADC};
enum DACINDEX {VREF_DS, VCASCN_PB, VCASCP_PB, VOUT_CM, VCASC_OUT, VIN_CM, VREF_COMP, IB_TESTC}; enum DACINDEX {VREF_DS, VCASCN_PB, VCASCP_PB, VOUT_CM, VCASC_OUT, VIN_CM, VREF_COMP, IB_TESTC};

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/jungfrauDetectorServer Path: slsDetectorPackage/slsDetectorServers/jungfrauDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 5a4122ae7c8dae1572e9db336de70183956e58c7 Repsitory UUID: 45b837b42a9f190cb68688fd2b1a8d77c3050578
Revision: 31 Revision: 34
Branch: refactor Branch: program2
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4481 Last Changed Rev: 4490
Last Changed Date: 2019-03-28 08:18:03.000000002 +0100 ../slsDetectorServer/slsDetectorFunctionList.h Last Changed Date: 2019-04-02 08:57:37.000000002 +0200 ../slsDetectorServer/slsDetectorServer_funcs.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "5a4122ae7c8dae1572e9db336de70183956e58c7" #define GITREPUUID "45b837b42a9f190cb68688fd2b1a8d77c3050578"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4481 #define GITREV 0x4490
#define GITDATE 0x20190328 #define GITDATE 0x20190402
#define GITBRANCH "refactor" #define GITBRANCH "program2"

View File

@ -3,11 +3,9 @@
#include "RegisterDefs.h" #include "RegisterDefs.h"
#define GOODBYE (-200)
#define MIN_REQRD_VRSN_T_RD_API 0x171220 #define MIN_REQRD_VRSN_T_RD_API 0x171220
#define REQRD_FRMWR_VRSN 0x181206 // temp bug fix from last version, timing mode is backwards compatible #define REQRD_FRMWR_VRSN 0x181206 // temp bug fix from last version, timing mode is backwards compatible
#define PROGRAMMING_MODE (0x2)
#define BOARD_JUNGFRAU_TYPE (8) #define BOARD_JUNGFRAU_TYPE (8)
#define CTRL_SRVR_INIT_TIME_US (300 * 1000) #define CTRL_SRVR_INIT_TIME_US (300 * 1000)

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/moenchDetectorServer Path: slsDetectorPackage/slsDetectorServers/moenchDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 5a4122ae7c8dae1572e9db336de70183956e58c7 Repsitory UUID: 45b837b42a9f190cb68688fd2b1a8d77c3050578
Revision: 26 Revision: 28
Branch: refactor Branch: program2
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4481 Last Changed Rev: 4490
Last Changed Date: 2019-03-28 09:08:53.000000002 +0100 ./slsDetectorFunctionList.c Last Changed Date: 2019-04-02 17:21:40.000000002 +0200 ./slsDetectorServer_defs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "5a4122ae7c8dae1572e9db336de70183956e58c7" #define GITREPUUID "45b837b42a9f190cb68688fd2b1a8d77c3050578"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4481 #define GITREV 0x4490
#define GITDATE 0x20190328 #define GITDATE 0x20190402
#define GITBRANCH "refactor" #define GITBRANCH "program2"

View File

@ -3,11 +3,9 @@
#include "RegisterDefs.h" #include "RegisterDefs.h"
#define GOODBYE (-200)
#define MIN_REQRD_VRSN_T_RD_API 0x180314 #define MIN_REQRD_VRSN_T_RD_API 0x180314
#define REQRD_FRMWR_VRSN 0x180314 #define REQRD_FRMWR_VRSN 0x180314
#define PROGRAMMING_MODE (0x2)
#define CTRL_SRVR_INIT_TIME_US (300 * 1000) #define CTRL_SRVR_INIT_TIME_US (300 * 1000)
/* Struct Definitions */ /* Struct Definitions */

View File

@ -245,9 +245,10 @@ void closeConnection(int file_des) {
void exitServer(int socketDescriptor) { void exitServer(int socketDescriptor) {
if (socketDescriptor >= 0) if (socketDescriptor >= 0)
close(socketDescriptor); close(socketDescriptor);
FILE_LOG(logDEBUG3, ("Closing %s server\n", (isControlServer ? "control":"stop"))); FILE_LOG(logINFO, ("Closing %s server\n", (isControlServer ? "control":"stop")));
FD_CLR(socketDescriptor, &readset); FD_CLR(socketDescriptor, &readset);
isock--; isock--;
fflush(stdout);
} }

View File

@ -37,7 +37,6 @@ int main(int argc, char *argv[]){
// subsequent read/write to socket gives error - must handle locally // subsequent read/write to socket gives error - must handle locally
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
// circumvent the basic tests // circumvent the basic tests
{ {
int i; int i;
@ -63,16 +62,6 @@ int main(int argc, char *argv[]){
FILE_LOG(logINFO, ("Detected phase shift of %d\n", phaseShift)); FILE_LOG(logINFO, ("Detected phase shift of %d\n", phaseShift));
} }
#endif #endif
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
else if(!strcasecmp(argv[i],"-update")){
FILE_LOG(logINFO, ("Detected update mode\n"));
debugflag = PROGRAMMING_MODE;
}
#endif
else if(strchr(argv[i],'-') != NULL) {
FILE_LOG(logERROR, ("cannot scan program argument %s\n", argv[1]));
return -1;
}
} }
} }
@ -116,7 +105,7 @@ int main(int argc, char *argv[]){
} }
// waits for connection // waits for connection
while(retval != GOODBYE) { while(retval != GOODBYE && retval != REBOOT) {
fd = acceptConnection(sockfd); fd = acceptConnection(sockfd);
if (fd > 0) { if (fd > 0) {
retval = decode_function(fd); retval = decode_function(fd);
@ -125,8 +114,13 @@ int main(int argc, char *argv[]){
} }
exitServer(sockfd); exitServer(sockfd);
FILE_LOG(logINFO,("Goodbye!\n"));
if (retval == REBOOT) {
FILE_LOG(logINFOBLUE,("Rebooting!\n"));
fflush(stdout);
system("reboot");
}
FILE_LOG(logINFO,("Goodbye!\n"));
return 0; return 0;
} }

View File

@ -58,9 +58,6 @@ void init_detector() {
#endif #endif
if (isControlServer) { if (isControlServer) {
basictests(); basictests();
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
if (debugflag != PROGRAMMING_MODE)
#endif
initControlServer(); initControlServer();
#ifdef EIGERD #ifdef EIGERD
dhcpipad = getDetectorIP(); dhcpipad = getDetectorIP();
@ -85,18 +82,6 @@ int decode_function(int file_des) {
} else } else
FILE_LOG(logDEBUG3, ("Received %d bytes\n", n )); FILE_LOG(logDEBUG3, ("Received %d bytes\n", n ));
// jungfrau in programming mode
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
if ((debugflag == PROGRAMMING_MODE) &&
(fnum != F_PROGRAM_FPGA) &&
(fnum != F_GET_DETECTOR_TYPE) &&
(fnum != F_RESET_FPGA) &&
(fnum != F_UPDATE_CLIENT) &&
(fnum != F_CHECK_VERSION)) {
ret = (M_nofuncMode)(file_des);
}
else
#endif
if (fnum < 0 || fnum >= NUM_DET_FUNCTIONS) { if (fnum < 0 || fnum >= NUM_DET_FUNCTIONS) {
FILE_LOG(logERROR, ("Unknown function enum %d\n", fnum)); FILE_LOG(logERROR, ("Unknown function enum %d\n", fnum));
ret=(M_nofunc)(file_des); ret=(M_nofunc)(file_des);
@ -109,11 +94,22 @@ int decode_function(int file_des) {
FILE_LOG(logDEBUG1, ("Error executing the function = %d (%s)\n", FILE_LOG(logDEBUG1, ("Error executing the function = %d (%s)\n",
fnum, getFunctionName((enum detFuncs)fnum))); fnum, getFunctionName((enum detFuncs)fnum)));
} else FILE_LOG(logDEBUG1, ("Function (%s) executed %s\n", } else FILE_LOG(logDEBUG1, ("Function (%s) executed %s\n",
getFunctionName((enum detFuncs)fnum), (ret == OK)?"OK":"FORCE_UPDATE")); getFunctionName((enum detFuncs)fnum), getRetName()));
} }
return ret; return ret;
} }
const char* getRetName() {
switch(ret) {
case OK: return "OK";
case FAIL: return "FAIL";
case FORCE_UPDATE: return "FORCE_UPDATE";
case GOODBYE: return "GOODBYE";
case REBOOT: return "REBOOT";
default: return "unknown";
}
}
const char* getTimerName(enum timerIndex ind) { const char* getTimerName(enum timerIndex ind) {
switch (ind) { switch (ind) {
case FRAME_NUMBER: return "frame_number"; case FRAME_NUMBER: return "frame_number";
@ -137,6 +133,7 @@ const char* getTimerName(enum timerIndex ind) {
} }
} }
const char* getSpeedName(enum speedVariable ind) { const char* getSpeedName(enum speedVariable ind) {
switch (ind) { switch (ind) {
case CLOCK_DIVIDER: return "clock_divider"; case CLOCK_DIVIDER: return "clock_divider";
@ -231,6 +228,8 @@ const char* getFunctionName(enum detFuncs func) {
case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER"; case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER";
case F_LED: return "F_LED"; case F_LED: return "F_LED";
case F_DIGITAL_IO_DELAY: return "F_DIGITAL_IO_DELAY"; case F_DIGITAL_IO_DELAY: return "F_DIGITAL_IO_DELAY";
case F_COPY_DET_SERVER: return "F_COPY_DET_SERVER";
case F_REBOOT_CONTROLLER: return "F_REBOOT_CONTROLLER";
default: return "Unknown Function"; default: return "Unknown Function";
} }
@ -301,6 +300,8 @@ void function_table() {
flist[F_SOFTWARE_TRIGGER] = &software_trigger; flist[F_SOFTWARE_TRIGGER] = &software_trigger;
flist[F_LED] = &led; flist[F_LED] = &led;
flist[F_DIGITAL_IO_DELAY] = &digital_io_delay; flist[F_DIGITAL_IO_DELAY] = &digital_io_delay;
flist[F_COPY_DET_SERVER] = &copy_detector_server;
flist[F_REBOOT_CONTROLLER] = &reboot_controller;
// check // check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -354,6 +355,39 @@ void validate64(int64_t arg, int64_t retval, char* modename, enum numberMode num
} }
} }
int executeCommand(char* command, char* result, enum TLogLevel level) {
const size_t tempsize = 256;
char temp[tempsize];
memset(temp, 0, tempsize);
memset(result, 0, MAX_STR_LENGTH);
FILE_LOG(level, ("Executing command:\n[%s]\n", command));
strcat(command, " 2>&1");
fflush(stdout);
FILE* sysFile = popen(command, "r");
while(fgets(temp, tempsize, sysFile) != NULL) {
// size left excludes terminating character
size_t sizeleft = MAX_STR_LENGTH - strlen(result) - 1;
// more than the command
if (tempsize > sizeleft) {
strncat(result, temp, sizeleft);
break;
}
strncat(result, temp, tempsize);
memset(temp, 0, tempsize);
}
int sucess = pclose(sysFile);
if (strlen(result)) {
if (sucess) {
sucess = FAIL;
FILE_LOG(logERROR, ("%s\n", result));
} else {
FILE_LOG(level, ("Result:\n[%s]\n", result));
}
}
return sucess;
}
int M_nofunc(int file_des) { int M_nofunc(int file_des) {
ret = FAIL; ret = FAIL;
@ -399,27 +433,10 @@ int exec_command(int file_des) {
if (receiveData(file_des, cmd, MAX_STR_LENGTH, OTHER) < 0) if (receiveData(file_des, cmd, MAX_STR_LENGTH, OTHER) < 0)
return printSocketReadError(); return printSocketReadError();
FILE_LOG(logINFO, ("Executing command (%s)\n", cmd));
// set // set
if (Server_VerifyLock() == OK) { if (Server_VerifyLock() == OK) {
FILE* sysFile = popen(cmd, "r"); ret = executeCommand(cmd, retval, logINFO);
const size_t tempsize = 256;
char temp[tempsize];
memset(temp, 0, tempsize);
while(fgets(temp, tempsize, sysFile) != NULL) {
// size left excludes terminating character
size_t sizeleft = MAX_STR_LENGTH - strlen(retval) - 1;
// more than the command
if (tempsize > sizeleft) {
strncat(retval, temp, sizeleft);
break;
}
strncat(retval, temp, tempsize);
memset(temp, 0, tempsize);
}
pclose(sysFile);
FILE_LOG(logINFO, ("Result of cmd (%s):\n%s\n", cmd, retval));
} }
return Server_SendResult(file_des, OTHER, NO_UPDATE, retval, sizeof(retval)); return Server_SendResult(file_des, OTHER, NO_UPDATE, retval, sizeof(retval));
} }
@ -2017,14 +2034,14 @@ int set_speed(int file_des) {
sprintf(validateName, "set %s", speedName); sprintf(validateName, "set %s", speedName);
#ifndef GOTTHARDD #ifndef GOTTHARDD
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(JUNGFRAUD) #if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(JUNGFRAUD)
if (ind == ADC_PHASE || ind == DBIT_PHASE && mode == 1) { if ((ind == ADC_PHASE || ind == DBIT_PHASE) && mode == 1) {
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) #if defined(CHIPTESTBOARDD) || defined(MOENCHD)
ret = validatePhaseinDegrees(ind, val, retval); ret = validatePhaseinDegrees(ind, val, retval);
#else #else
ret = validatePhaseinDegrees(val, retval); ret = validatePhaseinDegrees(val, retval);
#endif #endif
if (ret == FAIL) { if (ret == FAIL) {
sprintf(mess, "Could not set %s. Set %s, got %s\n", validateName); sprintf(mess, "Could not set %s. Set %d, got %d\n", validateName, val, retval);
FILE_LOG(logERROR,(mess)); FILE_LOG(logERROR,(mess));
} }
} else } else
@ -2138,14 +2155,7 @@ int set_port(int file_des) {
int update_client(int file_des) { int update_client(int file_des) {
ret = FORCE_UPDATE; ret = FORCE_UPDATE;
memset(mess, 0, sizeof(mess)); memset(mess, 0, sizeof(mess));
#if defined(JUNGFRAUD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
if (debugflag == PROGRAMMING_MODE) {
ret = OK;
}
#endif
Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0); Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0);
if (ret == OK)
return ret;
return send_update(file_des); return send_update(file_des);
} }
@ -3279,19 +3289,6 @@ int program_fpga(int file_des) {
// only set // only set
if (Server_VerifyLock() == OK) { if (Server_VerifyLock() == OK) {
// not in programming mode
if (debugflag != PROGRAMMING_MODE) {
//to receive any arguments
int n = 1;
while (n > 0)
n = receiveData(file_des, mess, MAX_STR_LENGTH, OTHER);
ret = FAIL;
sprintf(mess,"FPGA cannot be programmed in this mode. "
"Restart on-board detector server with -update for programming mode.\n");
FILE_LOG(logERROR,(mess));
}
else {
FILE_LOG(logINFOBLUE, ("Programming FPGA...\n")); FILE_LOG(logINFOBLUE, ("Programming FPGA...\n"));
size_t filesize = 0; size_t filesize = 0;
@ -3306,31 +3303,30 @@ int program_fpga(int file_des) {
totalsize = filesize; totalsize = filesize;
FILE_LOG(logDEBUG1, ("Total program size is: %d\n", totalsize)); FILE_LOG(logDEBUG1, ("Total program size is: %d\n", totalsize));
// opening file pointer to flash and telling FPGA to not touch flash // opening file pointer to flash and telling FPGA to not touch flash
if (startWritingFPGAprogram(&fp) != OK) { if (startWritingFPGAprogram(&fp) != OK) {
ret = FAIL; ret = FAIL;
sprintf(mess,"Could not write to flash. Error at startup.\n"); sprintf(mess,"Could not write to flash. Error at startup.\n");
FILE_LOG(logERROR,(mess)); FILE_LOG(logERROR,(mess));
} }
//---------------- first ret ----------------
Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0); Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0);
if (ret != FAIL) {
//erasing flash //erasing flash
if (ret != FAIL) {
eraseFlash(); eraseFlash();
fpgasrc = (char*)malloc(MAX_FPGAPROGRAMSIZE); fpgasrc = (char*)malloc(MAX_FPGAPROGRAMSIZE);
} }
//writing to flash part by part //writing to flash part by part
while(ret != FAIL && filesize) { while(ret != FAIL && filesize) {
unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb unitprogramsize = MAX_FPGAPROGRAMSIZE; //2mb
if (unitprogramsize > filesize) //less than 2mb if (unitprogramsize > filesize) //less than 2mb
unitprogramsize = filesize; unitprogramsize = filesize;
FILE_LOG(logDEBUG1, ("unit size to receive is:%d\n" FILE_LOG(logDEBUG1, ("unit size to receive is:%d\nfilesize:%d\n", unitprogramsize, filesize));
"filesize:%d\n", unitprogramsize, filesize));
//receive part of program //receive part of program
if (receiveData(file_des,fpgasrc,unitprogramsize,OTHER) < 0) if (receiveData(file_des,fpgasrc,unitprogramsize,OTHER) < 0)
@ -3345,12 +3341,7 @@ int program_fpga(int file_des) {
// write part to flash // write part to flash
ret = writeFPGAProgram(fpgasrc, unitprogramsize, fp); ret = writeFPGAProgram(fpgasrc, unitprogramsize, fp);
//---------------- middle rets ----------------
Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0); Server_SendResult(file_des, INT32, NO_UPDATE, NULL, 0);
if (ret == FAIL) { if (ret == FAIL) {
FILE_LOG(logERROR, ("Failure: Breaking out of program receiving\n")); FILE_LOG(logERROR, ("Failure: Breaking out of program receiving\n"));
} else { } else {
@ -3361,7 +3352,9 @@ int program_fpga(int file_des) {
} }
} }
printf("\n"); printf("\n");
FILE_LOG(logINFO, ("Done copying program or due to failure earlier\n")); if (ret == OK) {
FILE_LOG(logINFO, ("Done copying program\n"));
}
// closing file pointer to flash and informing FPGA // closing file pointer to flash and informing FPGA
stopWritingFPGAprogram(fp); stopWritingFPGAprogram(fp);
@ -3372,17 +3365,11 @@ int program_fpga(int file_des) {
if (fp != NULL) if (fp != NULL)
fclose(fp); fclose(fp);
FILE_LOG(logDEBUG1, ("Done with program receiving command\n")); FILE_LOG(logINFO, ("Completed program fpga command with %s\n", (ret == OK ? "success" : "fail")));
if (ret != FAIL && isControlServer) {
basictests();
initControlServer();
}
}
} }
#endif #endif
#endif #endif
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0); return ret;
} }
@ -3401,7 +3388,6 @@ int reset_fpga(int file_des) {
if (Server_VerifyLock() == OK) { if (Server_VerifyLock() == OK) {
if (isControlServer) { if (isControlServer) {
basictests(); // mapping of control server at least basictests(); // mapping of control server at least
if (debugflag != PROGRAMMING_MODE)
initControlServer(); initControlServer();
} }
else initStopServer(); //remapping of stop server else initStopServer(); //remapping of stop server
@ -3786,6 +3772,83 @@ int digital_io_delay(int file_des) {
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0); return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
} }
int copy_detector_server(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
char args[2][MAX_STR_LENGTH];
char retvals[MAX_STR_LENGTH] = {0};
memset(args, 0, sizeof(args));
memset(retvals, 0, sizeof(retvals));
if (receiveData(file_des, args, sizeof(args), OTHER) < 0)
return printSocketReadError();
#ifdef EIGERD
functionNotImplemented();
#else
// only set
if (Server_VerifyLock() == OK) {
char* sname = args[0];
char* hostname = args[1];
FILE_LOG(logINFOBLUE, ("Copying server %s from host %s\n", sname, hostname));
char cmd[MAX_STR_LENGTH];
memset(cmd, 0, MAX_STR_LENGTH);
// copy server
sprintf(cmd, "tftp %s -r %s -g", hostname, sname);
int success = executeCommand(cmd, retvals, logDEBUG1);
if (success == FAIL) {
ret = FAIL;
strcpy(mess, retvals);
//FILE_LOG(logERROR, (mess)); already printed in executecommand
}
// success
else {
FILE_LOG(logINFO, ("Server copied successfully\n"));
// give permissions
sprintf(cmd, "chmod 777 %s", sname);
executeCommand(cmd, retvals, logDEBUG1);
// edit /etc/inittab
// find line numbers in /etc/inittab where DetectorServer
strcpy(cmd, "sed -n '/DetectorServer/=' /etc/inittab");
executeCommand(cmd, retvals, logDEBUG1);
while (strlen(retvals)) {
// get first linen number
int lineNumber = atoi(retvals);
// delete that line
sprintf(cmd, "sed -i \'%dd\' /etc/inittab", lineNumber);
executeCommand(cmd, retvals, logDEBUG1);
// find line numbers again
strcpy(cmd, "sed -n '/DetectorServer/=' /etc/inittab");
executeCommand(cmd, retvals, logDEBUG1);
}
FILE_LOG(logINFO, ("Deleted all lines containing DetectorServer in /etc/inittab\n"));
// append line
sprintf(cmd, "echo \"ttyS0::respawn:/./%s\" >> /etc/inittab", sname);
executeCommand(cmd, retvals, logDEBUG1);
FILE_LOG(logINFO, ("/etc/inittab modified to have %s\n", sname));
}
}
#endif
return Server_SendResult(file_des, OTHER, NO_UPDATE, retvals, sizeof(retvals));
}
int reboot_controller(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
#ifdef EIGERD
functionNotImplemented();
return ret;
#else
FILE_LOG(logINFORED, ("Rebooting controller\n"));
return REBOOT;
#endif
}

View File

@ -1,12 +1,16 @@
#pragma once #pragma once
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "logger.h"
enum numberMode {DEC, HEX}; enum numberMode {DEC, HEX};
#define GOODBYE (-200)
#define REBOOT (-400)
// initialization functions // initialization functions
int printSocketReadError(); int printSocketReadError();
void init_detector(); void init_detector();
int decode_function(int); int decode_function(int);
const char* getRetName();
const char* getTimerName(enum timerIndex ind); const char* getTimerName(enum timerIndex ind);
const char* getSpeedName(enum speedVariable ind); const char* getSpeedName(enum speedVariable ind);
const char* getFunctionName(enum detFuncs func); const char* getFunctionName(enum detFuncs func);
@ -15,6 +19,7 @@ void functionNotImplemented();
void modeNotImplemented(char* modename, int mode); void modeNotImplemented(char* modename, int mode);
void validate(int arg, int retval, char* modename, enum numberMode nummode); void validate(int arg, int retval, char* modename, enum numberMode nummode);
void validate64(int64_t arg, int64_t retval, char* modename, enum numberMode nummode); void validate64(int64_t arg, int64_t retval, char* modename, enum numberMode nummode);
int executeCommand(char* command, char* result, enum TLogLevel level);
int M_nofunc(int); int M_nofunc(int);
int M_nofuncMode(int); int M_nofuncMode(int);
@ -85,3 +90,6 @@ int check_version(int);
int software_trigger(int); int software_trigger(int);
int led(int); int led(int);
int digital_io_delay(int); int digital_io_delay(int);
int copy_detector_server(int);
int reboot_controller(int);

View File

@ -1,12 +1,5 @@
#ifndef MULTI_SLS_DETECTOR_H #pragma once
#define MULTI_SLS_DETECTOR_H
/**
@libdoc The multiSlsDetector class is used to operate several slsDetectors in
parallel.
* @short This is the base class for multi detector system functionalities
* @author Anna Bergamaschi
*/
#include "SharedMemory.h" #include "SharedMemory.h"
#include "error_defs.h" #include "error_defs.h"
#include "gitInfoLib.h" #include "gitInfoLib.h"
@ -1434,7 +1427,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
int setStoragecellStart(int pos = -1, int detPos = -1); int setStoragecellStart(int pos = -1, int detPos = -1);
/** /**
* Programs FPGA with pof file (Jungfrau) * Programs FPGA with pof file (Not Eiger)
* @param fname file name * @param fname file name
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL * @returns OK or FAIL
@ -1442,12 +1435,38 @@ class multiSlsDetector : public virtual slsDetectorDefs {
int programFPGA(const std::string &fname, int detPos = -1); int programFPGA(const std::string &fname, int detPos = -1);
/** /**
* Resets FPGA (Jungfrau) * Resets FPGA (Not Eiger)
* @param detPos -1 for all detectors in list or specific detector position * @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int resetFPGA(int detPos = -1); int resetFPGA(int detPos = -1);
/**
* Copies detector server from tftp and changes respawn server (Not Eiger)
* @param fname name of detector server binary
* @param hostname name of pc to tftp from
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL
*/
int copyDetectorServer(const std::string &fname, const std::string &hostname, int detPos = -1);
/**
* Reboot detector controller (Not Eiger)
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL
*/
int rebootController(int detPos = -1);
/**
* Updates the firmware, detector server and then reboots detector controller blackfin. (Not Eiger)
* @param sname name of detector server binary
* @param hostname name of pc to tftp from
* @param fname programming file name
* @param detPos -1 for all detectors in list or specific detector position
* @returns OK or FAIL
*/
int update(const std::string &sname, const std::string &hostname, const std::string &fname, int detPos = -1);
/** /**
* Power on/off Chip (Jungfrau) * Power on/off Chip (Jungfrau)
* @param ival on is 1, off is 0, -1 to get * @param ival on is 1, off is 0, -1 to get
@ -2010,11 +2029,6 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/ */
void startProcessingThread(); void startProcessingThread();
// /**
// * Static function to call processing thread
// */
// static void* startProcessData(void *n);
/** /**
* Check if processing thread is ready to join main thread * Check if processing thread is ready to join main thread
* @returns true if ready, else false * @returns true if ready, else false
@ -2033,6 +2047,15 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/ */
int kbhit(); int kbhit();
/**
* Convert raw file
* @param fname name of pof file
* @param fpgasrc pointer in memory to read pof to
* @returns file size
*/
std::vector<char> readPofFile(const std::string &fname);
/** Multi detector Id */ /** Multi detector Id */
const int multiId; const int multiId;
@ -2091,4 +2114,3 @@ class multiSlsDetector : public virtual slsDetectorDefs {
void *pCallbackArg{nullptr}; void *pCallbackArg{nullptr};
}; };
#endif

View File

@ -1,13 +1,4 @@
#ifndef SLS_DETECTOR_H #pragma once
#define SLS_DETECTOR_H
/**
*
* @short complete detector functionalities for a single module detector.
* The slsDetector class takes care of the communication with the
* detector and all kind actions related with a single detector controller
* @author Anna Bergamaschi
*/
#include "ClientSocket.h" #include "ClientSocket.h"
#include "SharedMemory.h" #include "SharedMemory.h"
@ -18,6 +9,7 @@
class ClientInterface; class ClientInterface;
#include <cmath> #include <cmath>
#include <vector>
class multiSlsDetector; class multiSlsDetector;
class ServerInterface; class ServerInterface;
@ -796,7 +788,7 @@ class slsDetector : public virtual slsDetectorDefs{
* @param detectorMAC detector MAC address * @param detectorMAC detector MAC address
* @returns the detector MAC address * @returns the detector MAC address
*/ */
std::string setDetectorMAC(const std::string &address); std::string setDetectorMAC(const std::string &detectorMAC);
/** /**
* Returns the detector MAC address\sa sharedSlsDetector * Returns the detector MAC address\sa sharedSlsDetector
@ -809,7 +801,7 @@ class slsDetector : public virtual slsDetectorDefs{
* @param detectorMAC detector MAC address (bottom half) * @param detectorMAC detector MAC address (bottom half)
* @returns the detector MAC address (bottom half) * @returns the detector MAC address (bottom half)
*/ */
std::string setDetectorMAC2(const std::string &address); std::string setDetectorMAC2(const std::string &detectorMAC);
/** /**
* Returns the detector MAC address (bottom half) Jungfrau only * Returns the detector MAC address (bottom half) Jungfrau only
@ -1283,11 +1275,11 @@ class slsDetector : public virtual slsDetectorDefs{
int setStoragecellStart(int pos = -1); int setStoragecellStart(int pos = -1);
/** /**
* Programs FPGA with pof file (Jungfrau) * Programs FPGA with pof file (Jungfrau, CTB, Moench)
* @param fname file name * @param buffer programming file in memory
* @returns OK or FAIL * @returns OK or FAIL
*/ */
int programFPGA(const std::string &fname); int programFPGA(std::vector<char> buffer);
/** /**
* Resets FPGA (Jungfrau) * Resets FPGA (Jungfrau)
@ -1295,6 +1287,20 @@ class slsDetector : public virtual slsDetectorDefs{
*/ */
int resetFPGA(); int resetFPGA();
/**
* Copies detector server from tftp and changes respawn server (Not Eiger)
* @param fname name of detector server binary
* @param hostname name of pc to tftp from
* @returns OK or FAIL
*/
int copyDetectorServer(const std::string &fname, const std::string &hostname);
/**
* Reboot detector controller (blackfin/ powerpc)
* @returns OK or FAIL
*/
int rebootController();
/** /**
* Power on/off Chip (Jungfrau) * Power on/off Chip (Jungfrau)
* @param ival on is 1, off is 0, -1 to get * @param ival on is 1, off is 0, -1 to get
@ -1823,4 +1829,3 @@ class slsDetector : public virtual slsDetectorDefs{
}; };
#endif

View File

@ -2624,13 +2624,17 @@ int multiSlsDetector::setStoragecellStart(int pos, int detPos) {
} }
int multiSlsDetector::programFPGA(const std::string &fname, int detPos) { int multiSlsDetector::programFPGA(const std::string &fname, int detPos) {
FILE_LOG(logINFO) << "This can take awhile. Please be patient...";
// read pof file
std::vector<char> buffer = readPofFile(fname);
// single // single
if (detPos >= 0) { if (detPos >= 0) {
return detectors[detPos]->programFPGA(fname); return detectors[detPos]->programFPGA(buffer);
} }
// multi // multi
auto r = serialCall(&slsDetector::programFPGA, fname); auto r = parallelCall(&slsDetector::programFPGA, buffer);
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL; return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
} }
@ -2645,6 +2649,47 @@ int multiSlsDetector::resetFPGA(int detPos) {
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL; return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
} }
int multiSlsDetector::copyDetectorServer(const std::string &fname, const std::string &hostname, int detPos) {
// single
if (detPos >= 0) {
detectors[detPos]->copyDetectorServer(fname, hostname);
return detectors[detPos]->rebootController(); // reboot and copy should be independant for update command
}
// multi
parallelCall(&slsDetector::copyDetectorServer,fname, hostname);
auto r = parallelCall(&slsDetector::rebootController);
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
}
int multiSlsDetector::rebootController(int detPos) {
// single
if (detPos >= 0) {
return detectors[detPos]->rebootController();
}
// multi
auto r = parallelCall(&slsDetector::rebootController);
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
}
int multiSlsDetector::update(const std::string &sname, const std::string &hostname, const std::string &fname, int detPos) {
FILE_LOG(logINFO) << "This can take awhile. Please be patient...";
// read pof file
std::vector<char> buffer = readPofFile(fname);
// single
if (detPos >= 0) {
detectors[detPos]->copyDetectorServer(sname, hostname);
return detectors[detPos]->programFPGA(buffer);
}
// multi
parallelCall(&slsDetector::copyDetectorServer,sname, hostname);
auto r = parallelCall(&slsDetector::programFPGA, buffer);
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
}
int multiSlsDetector::powerChip(int ival, int detPos) { int multiSlsDetector::powerChip(int ival, int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
@ -4013,10 +4058,6 @@ void multiSlsDetector::startProcessingThread() {
dataProcessingThread = std::thread(&multiSlsDetector::processData, this); dataProcessingThread = std::thread(&multiSlsDetector::processData, this);
} }
// void* multiSlsDetector::startProcessData(void *n) {
// ((multiSlsDetector*)n)->processData();
// return n;
// }
void multiSlsDetector::processData() { void multiSlsDetector::processData() {
if (setReceiverOnline() == OFFLINE_FLAG) { if (setReceiverOnline() == OFFLINE_FLAG) {
@ -4077,3 +4118,107 @@ int multiSlsDetector::kbhit() {
select(STDIN_FILENO + 1, &fds, nullptr, nullptr, &tv); select(STDIN_FILENO + 1, &fds, nullptr, nullptr, &tv);
return FD_ISSET(STDIN_FILENO, &fds); return FD_ISSET(STDIN_FILENO, &fds);
} }
std::vector<char> multiSlsDetector::readPofFile(const std::string &fname) {
FILE_LOG(logDEBUG1) << "Programming FPGA with file name:" << fname;
size_t filesize = 0;
// check if it exists
struct stat st;
if (stat(fname.c_str(), &st)) {
throw RuntimeError("Program FPGA: Programming file does not exist");
}
// open src
FILE *src = fopen(fname.c_str(), "rb");
if (src == nullptr) {
throw RuntimeError("Program FPGA: Could not open source file for programming: " +
fname);
}
// create temp destination file
char destfname[] = "/tmp/SLS_DET_MCB.XXXXXX";
int dst = mkstemp(destfname); // create temporary file and open it in r/w
if (dst == -1) {
fclose(src);
throw RuntimeError(
std::string("Could not create destination file in /tmp for programming: ") +
destfname);
}
// convert src to dst rawbin
FILE_LOG(logDEBUG1) << "Converting " << fname << " to " << destfname;
{
int filepos, x, y, i;
// Remove header (0...11C)
for (filepos = 0; filepos < 0x11C; ++filepos) {
fgetc(src);
}
// Write 0x80 times 0xFF (0...7F)
{
char c = 0xFF;
for (filepos = 0; filepos < 0x80; ++filepos) {
write(dst, &c, 1);
}
}
// Swap bits and write to file
for (filepos = 0x80; filepos < 0x1000000; ++filepos) {
x = fgetc(src);
if (x < 0) {
break;
}
y = 0;
for (i = 0; i < 8; ++i) {
y = y | (((x & (1 << i)) >> i) << (7 - i)); // This swaps the bits
}
write(dst, &y, 1);
}
if (filepos < 0x1000000) {
throw RuntimeError("Could not convert programming file. EOF before end of flash");
}
}
if (fclose(src)) {
throw RuntimeError("Program FPGA: Could not close source file");
}
if (close(dst)) {
throw RuntimeError("Program FPGA: Could not close destination file");
}
FILE_LOG(logDEBUG1) << "File has been converted to " << destfname;
// loading dst file to memory
FILE *fp = fopen(destfname, "r");
if (fp == nullptr) {
throw RuntimeError("Program FPGA: Could not open rawbin file");
}
if (fseek(fp, 0, SEEK_END)) {
throw RuntimeError("Program FPGA: Seek error in rawbin file");
}
filesize = ftell(fp);
if (filesize <= 0) {
throw RuntimeError("Program FPGA: Could not get length of rawbin file");
}
rewind(fp);
std::vector<char> buffer(filesize, 0);
if (fread(buffer.data(), sizeof(char), filesize, fp) != filesize) {
throw RuntimeError("Program FPGA: Could not read rawbin file");
}
if (fclose(fp)) {
throw RuntimeError("Program FPGA: Could not close destination file after converting");
}
unlink(destfname); // delete temporary file
FILE_LOG(logDEBUG1) << "Successfully loaded the rawbin file to program memory";
FILE_LOG(logINFO) << "Read file into memory";
return buffer;
}

View File

@ -845,8 +845,10 @@ int slsDetector::execCommand(const std::string &cmd) {
if (detector_shm()->onlineFlag == ONLINE_FLAG) { if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname, detector_shm()->controlPort); auto client = DetectorSocket(detector_shm()->hostname, detector_shm()->controlPort);
ret = client.sendCommandThenRead(fnum, arg, sizeof(arg), retval, sizeof(retval)); ret = client.sendCommandThenRead(fnum, arg, sizeof(arg), retval, sizeof(retval));
if (strlen(retval)) {
FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval; FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval;
} }
}
return ret; return ret;
} }
@ -1597,12 +1599,12 @@ int slsDetector::configureMAC() {
// copy to args and convert to hex // copy to args and convert to hex
snprintf(args[0], array_size, "%x", detector_shm()->receiverUDPPort); snprintf(args[0], array_size, "%x", detector_shm()->receiverUDPPort);
sls::strcpy_safe(args[1], getReceiverUDPIP().str()); //TODO! Why not hex? sls::strcpy_safe(args[1], getReceiverUDPIP().hex());
sls::strcpy_safe(args[2], getReceiverUDPMAC().hex()); sls::strcpy_safe(args[2], getReceiverUDPMAC().hex());
sls::strcpy_safe(args[3], getDetectorIP().hex()); sls::strcpy_safe(args[3], getDetectorIP().hex());
sls::strcpy_safe(args[4], getDetectorMAC().hex()); sls::strcpy_safe(args[4], getDetectorMAC().hex());
snprintf(args[5], array_size, "%x", detector_shm()->receiverUDPPort2); snprintf(args[5], array_size, "%x", detector_shm()->receiverUDPPort2);
sls::strcpy_safe(args[6], getReceiverUDPIP2().str()); sls::strcpy_safe(args[6], getReceiverUDPIP2().hex());
sls::strcpy_safe(args[7], getReceiverUDPMAC2().hex()); sls::strcpy_safe(args[7], getReceiverUDPMAC2().hex());
sls::strcpy_safe(args[8], getDetectorIP2().hex()); sls::strcpy_safe(args[8], getDetectorIP2().hex());
sls::strcpy_safe(args[9], getDetectorMAC2().hex()); sls::strcpy_safe(args[9], getDetectorMAC2().hex());
@ -2036,14 +2038,14 @@ std::string slsDetector::setDetectorMAC(const std::string &address) {
auto addr = MacAddr(address); auto addr = MacAddr(address);
if (addr == 0) { if (addr == 0) {
throw RuntimeError("server MAC Address should be in xx:xx:xx:xx:xx:xx format"); throw RuntimeError("server MAC Address should be in xx:xx:xx:xx:xx:xx format");
} else { }
detector_shm()->detectorMAC = addr; detector_shm()->detectorMAC = addr;
if (!strcmp(detector_shm()->receiver_hostname, "none")) { if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
} else if (setUDPConnection() == FAIL) { } else if (setUDPConnection() == FAIL) {
FILE_LOG(logWARNING) << "UDP connection set up failed"; FILE_LOG(logWARNING) << "UDP connection set up failed";
} }
}
return getDetectorMAC().str(); return getDetectorMAC().str();
} }
@ -2053,14 +2055,13 @@ std::string slsDetector::setDetectorMAC2(const std::string &address) {
auto addr = MacAddr(address); auto addr = MacAddr(address);
if (addr == 0) { if (addr == 0) {
throw RuntimeError("server MAC Address 2 should be in xx:xx:xx:xx:xx:xx format"); throw RuntimeError("server MAC Address 2 should be in xx:xx:xx:xx:xx:xx format");
} else { }
detector_shm()->detectorMAC2 = addr; detector_shm()->detectorMAC2 = addr;
if (!strcmp(detector_shm()->receiver_hostname, "none")) { if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
} else if (setUDPConnection() == FAIL) { } else if (setUDPConnection() == FAIL) {
FILE_LOG(logWARNING) << "UDP connection set up failed"; FILE_LOG(logWARNING) << "UDP connection set up failed";
} }
}
return getDetectorMAC2().str(); return getDetectorMAC2().str();
} }
@ -2068,17 +2069,16 @@ MacAddr slsDetector::getDetectorMAC2() { return detector_shm()->detectorMAC2; }
std::string slsDetector::setDetectorIP(const std::string &ip) { std::string slsDetector::setDetectorIP(const std::string &ip) {
auto addr = IpAddr(ip); auto addr = IpAddr(ip);
if (addr != 0) { if (addr == 0) {
throw RuntimeError("setDetectorIP: IP Address should be VALID and "
"in xxx.xxx.xxx.xxx format");
}
detector_shm()->detectorIP = ip; detector_shm()->detectorIP = ip;
if (!strcmp(detector_shm()->receiver_hostname, "none")) { if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
} else if (setUDPConnection() == FAIL) { } else if (setUDPConnection() == FAIL) {
FILE_LOG(logWARNING) << "UDP connection set up failed"; FILE_LOG(logWARNING) << "UDP connection set up failed";
} }
} else {
throw RuntimeError("setDetectorIP: IP Address should be VALID and "
"in xxx.xxx.xxx.xxx format");
}
return getDetectorIP().str(); return getDetectorIP().str();
} }
@ -2086,17 +2086,16 @@ IpAddr slsDetector::getDetectorIP() const { return detector_shm()->detectorIP; }
std::string slsDetector::setDetectorIP2(const std::string &ip) { std::string slsDetector::setDetectorIP2(const std::string &ip) {
auto addr = IpAddr(ip); auto addr = IpAddr(ip);
if (addr != 0) { if (addr == 0) {
throw RuntimeError("setDetectorIP: IP2 Address should be VALID and "
"in xxx.xxx.xxx.xxx format");
}
detector_shm()->detectorIP2 = ip; detector_shm()->detectorIP2 = ip;
if (!strcmp(detector_shm()->receiver_hostname, "none")) { if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
} else if (setUDPConnection() == FAIL) { } else if (setUDPConnection() == FAIL) {
FILE_LOG(logWARNING) << "UDP connection set up failed"; FILE_LOG(logWARNING) << "UDP connection set up failed";
} }
} else {
throw RuntimeError("setDetectorIP: IP2 Address should be VALID and "
"in xxx.xxx.xxx.xxx format");
}
return getDetectorIP().str(); return getDetectorIP().str();
} }
@ -2233,7 +2232,7 @@ std::string slsDetector::setReceiverUDPIP(const std::string &udpip) {
if (ip == 0) { if (ip == 0) {
throw ReceiverError("setReceiverUDPIP: UDP IP Address should be " throw ReceiverError("setReceiverUDPIP: UDP IP Address should be "
"VALID and in xxx.xxx.xxx.xxx format"); "VALID and in xxx.xxx.xxx.xxx format");
} else { }
detector_shm()->receiverUDPIP = ip; detector_shm()->receiverUDPIP = ip;
if (!strcmp(detector_shm()->receiver_hostname, "none")) { if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
@ -2242,7 +2241,6 @@ std::string slsDetector::setReceiverUDPIP(const std::string &udpip) {
} }
return getReceiverUDPIP().str(); return getReceiverUDPIP().str();
} }
}
sls::IpAddr slsDetector::getReceiverUDPIP() const { return detector_shm()->receiverUDPIP; } sls::IpAddr slsDetector::getReceiverUDPIP() const { return detector_shm()->receiverUDPIP; }
@ -2251,7 +2249,7 @@ std::string slsDetector::setReceiverUDPIP2(const std::string &udpip) {
if (ip == 0) { if (ip == 0) {
throw ReceiverError("setReceiverUDPIP: UDP IP Address 2 should be " throw ReceiverError("setReceiverUDPIP: UDP IP Address 2 should be "
"VALID and in xxx.xxx.xxx.xxx format"); "VALID and in xxx.xxx.xxx.xxx format");
} else { }
detector_shm()->receiverUDPIP2 = ip; detector_shm()->receiverUDPIP2 = ip;
if (!strcmp(detector_shm()->receiver_hostname, "none")) { if (!strcmp(detector_shm()->receiver_hostname, "none")) {
FILE_LOG(logDEBUG1) << "Receiver hostname not set yet"; FILE_LOG(logDEBUG1) << "Receiver hostname not set yet";
@ -2260,7 +2258,6 @@ std::string slsDetector::setReceiverUDPIP2(const std::string &udpip) {
} }
return getReceiverUDPIP2().str(); return getReceiverUDPIP2().str();
} }
}
sls::IpAddr slsDetector::getReceiverUDPIP2() const { return detector_shm()->receiverUDPIP2; } sls::IpAddr slsDetector::getReceiverUDPIP2() const { return detector_shm()->receiverUDPIP2; }
@ -3259,143 +3256,45 @@ int slsDetector::setStoragecellStart(int pos) {
return retval; return retval;
} }
int slsDetector::programFPGA(const std::string &fname) { int slsDetector::programFPGA(std::vector<char> buffer) {
// TODO! make exception safe! // validate type
// now malloced memory can leak switch(detector_shm()->myDetectorType) {
// only jungfrau implemented (client processing, so check now) case JUNGFRAU:
if (detector_shm()->myDetectorType != JUNGFRAU && case CHIPTESTBOARD:
detector_shm()->myDetectorType != CHIPTESTBOARD && case MOENCH:
detector_shm()->myDetectorType != MOENCH) { break;
default:
throw RuntimeError("Program FPGA is not implemented for this detector"); throw RuntimeError("Program FPGA is not implemented for this detector");
} }
FILE_LOG(logDEBUG1) << "Programming FPGA with file name:" << fname;
size_t filesize = 0;
char *fpgasrc = nullptr;
// check if it exists size_t filesize = buffer.size();
{
struct stat st;
if (stat(fname.c_str(), &st)) {
throw RuntimeError("Program FPGA: Programming file does not exist");
}
}
{
// open src
FILE *src = fopen(fname.c_str(), "rb");
if (src == nullptr) {
throw RuntimeError("Program FPGA: Could not open source file for programming: " +
fname);
}
// create temp destination file
char destfname[] = "/tmp/SLS_DET_MCB.XXXXXX";
int dst = mkstemp(destfname); // create temporary file and open it in r/w
if (dst == -1) {
fclose(src);
throw RuntimeError(std::string("Could not create destination file "
"in /tmp for programming: ") +
destfname);
}
// convert src to dst rawbin
FILE_LOG(logDEBUG1) << "Converting " << fname << " to " << destfname;
{
int filepos, x, y, i;
// Remove header (0...11C)
for (filepos = 0; filepos < 0x11C; ++filepos) {
fgetc(src);
}
// Write 0x80 times 0xFF (0...7F)
{
char c = 0xFF;
for (filepos = 0; filepos < 0x80; ++filepos) {
write(dst, &c, 1);
}
}
// Swap bits and write to file
for (filepos = 0x80; filepos < 0x1000000; ++filepos) {
x = fgetc(src);
if (x < 0) {
break;
}
y = 0;
for (i = 0; i < 8; ++i) {
y = y | (((x & (1 << i)) >> i) << (7 - i)); // This swaps the bits
}
write(dst, &y, 1);
}
if (filepos < 0x1000000) {
throw RuntimeError("Could not convert programming file. EOF "
"before end of flash");
}
}
if (fclose(src)) {
throw RuntimeError("Program FPGA: Could not close source file");
}
if (close(dst)) {
throw RuntimeError("Program FPGA: Could not close destination file");
}
FILE_LOG(logDEBUG1) << "File has been converted to " << destfname;
// loading dst file to memory
FILE *fp = fopen(destfname, "r");
if (fp == nullptr) {
throw RuntimeError("Program FPGA: Could not open rawbin file");
}
if (fseek(fp, 0, SEEK_END)) {
throw RuntimeError("Program FPGA: Seek error in rawbin file");
}
filesize = ftell(fp);
if (filesize <= 0) {
throw RuntimeError("Program FPGA: Could not get length of rawbin file");
}
rewind(fp);
fpgasrc = (char *)malloc(filesize + 1); //<------------------- MALLOC!
if (fpgasrc == nullptr) {
throw RuntimeError("Program FPGA: Could not allocate size of program");
}
if (fread(fpgasrc, sizeof(char), filesize, fp) != filesize) {
free(fpgasrc);
throw RuntimeError("Program FPGA: Could not read rawbin file");
}
if (fclose(fp)) {
free(fpgasrc);
throw RuntimeError("Program FPGA: Could not close destination file "
"after converting");
}
unlink(destfname); // delete temporary file
FILE_LOG(logDEBUG1) << "Successfully loaded the rawbin file to program memory";
}
// send program from memory to detector // send program from memory to detector
int fnum = F_PROGRAM_FPGA; int fnum = F_PROGRAM_FPGA;
int ret = FAIL; int ret = FAIL;
char mess[MAX_STR_LENGTH] = {0}; char mess[MAX_STR_LENGTH] = {0};
FILE_LOG(logDEBUG1) << "Sending programming binary to detector"; FILE_LOG(logINFO) << "Sending programming binary to detector " << detId << " (" << detector_shm()->hostname << ")";
if (detector_shm()->onlineFlag == ONLINE_FLAG) { if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname, detector_shm()->controlPort); auto client = DetectorSocket(detector_shm()->hostname, detector_shm()->controlPort);
client.sendData(&fnum, sizeof(fnum)); client.sendData(&fnum, sizeof(fnum));
client.sendData(&filesize, sizeof(filesize)); client.sendData(&filesize, sizeof(filesize));
client.receiveData(&ret, sizeof(ret)); client.receiveData(&ret, sizeof(ret));
// opening error // error in detector at opening file pointer to flash
if (ret == FAIL) { if (ret == FAIL) {
client.receiveData(mess, sizeof(mess)); client.receiveData(mess, sizeof(mess));
free(fpgasrc); std::ostringstream os;
throw RuntimeError("Detector " + std::to_string(detId) + os << "Detector " << detId << " (" << detector_shm()->hostname << ")" <<
" returned error: " + std::string(mess)); " returned error: " << mess;
throw RuntimeError(os.str());
} }
// erasing flash // erasing flash
if (ret != FAIL) { if (ret != FAIL) {
FILE_LOG(logINFO) << "This can take awhile. Please be patient..."; FILE_LOG(logINFO) << "Erasing Flash for detector " << detId << " (" << detector_shm()->hostname << ")";
FILE_LOG(logINFO) << "Erasing Flash:";
printf("%d%%\r", 0); printf("%d%%\r", 0);
std::cout << std::flush; std::cout << std::flush;
// erasing takes 65 seconds, printing here (otherwise need threads // erasing takes 65 seconds, printing here (otherwise need threads in server-unnecessary)
// in server-unnecessary)
const int ERASE_TIME = 65; const int ERASE_TIME = 65;
int count = ERASE_TIME + 1; int count = ERASE_TIME + 1;
while (count > 0) { while (count > 0) {
@ -3405,7 +3304,7 @@ int slsDetector::programFPGA(const std::string &fname) {
std::cout << std::flush; std::cout << std::flush;
} }
printf("\n"); printf("\n");
FILE_LOG(logINFO) << "Writing to Flash:"; FILE_LOG(logINFO) << "Writing to Flash to detector " << detId << " (" << detector_shm()->hostname << ")";
printf("%d%%\r", 0); printf("%d%%\r", 0);
std::cout << std::flush; std::cout << std::flush;
} }
@ -3423,7 +3322,7 @@ int slsDetector::programFPGA(const std::string &fname) {
FILE_LOG(logDEBUG1) << "unitprogramsize:" << unitprogramsize FILE_LOG(logDEBUG1) << "unitprogramsize:" << unitprogramsize
<< "\t filesize:" << filesize; << "\t filesize:" << filesize;
client.sendData(fpgasrc + currentPointer, unitprogramsize); client.sendData(&buffer[currentPointer], unitprogramsize);
client.receiveData(&ret, sizeof(ret)); client.receiveData(&ret, sizeof(ret));
if (ret != FAIL) { if (ret != FAIL) {
filesize -= unitprogramsize; filesize -= unitprogramsize;
@ -3435,47 +3334,21 @@ int slsDetector::programFPGA(const std::string &fname) {
} else { } else {
printf("\n"); printf("\n");
client.receiveData(mess, sizeof(mess)); client.receiveData(mess, sizeof(mess));
free(fpgasrc); std::ostringstream os;
throw RuntimeError("Detector returned error: " + std::string(mess)); os << "Detector " << detId << " (" << detector_shm()->hostname << ")" <<
" returned error: " << mess;
throw RuntimeError(os.str());
} }
} }
printf("\n"); printf("\n");
// check ending error
if ((ret == FAIL) && (strstr(mess, "not implemented") == nullptr) &&
(strstr(mess, "locked") == nullptr) && (strstr(mess, "-update") == nullptr)) {
client.receiveData(&ret, sizeof(ret));
if (ret == FAIL) {
client.receiveData(mess, sizeof(mess));
free(fpgasrc);
throw RuntimeError("Detector returned error: " + std::string(mess));
} }
if (ret != FAIL) {
ret = rebootController();
} }
if (ret == FORCE_UPDATE) {
updateDetector();
}
// remapping stop server
if ((ret == FAIL) && (strstr(mess, "not implemented") == nullptr) &&
(strstr(mess, "locked") == nullptr) && (strstr(mess, "-update") == nullptr)) {
fnum = F_RESET_FPGA;
int stopret = FAIL;
auto stop = DetectorSocket(detector_shm()->hostname, detector_shm()->stopPort);
stop.sendData(&fnum, sizeof(fnum));
stop.receiveData(&stopret, sizeof(stopret));
if (stopret == FAIL) {
client.receiveData(mess, sizeof(mess));
free(fpgasrc);
throw RuntimeError("Detector returned error: " + std::string(mess));
}
}
}
FILE_LOG(logINFO) << "You can now restart the detector servers in normal mode.";
free(fpgasrc);
return ret; return ret;
} }
int slsDetector::resetFPGA() { int slsDetector::resetFPGA() {
int fnum = F_RESET_FPGA; int fnum = F_RESET_FPGA;
int ret = FAIL; int ret = FAIL;
@ -3490,6 +3363,37 @@ int slsDetector::resetFPGA() {
return ret; return ret;
} }
int slsDetector::copyDetectorServer(const std::string &fname, const std::string &hostname) {
int fnum = F_COPY_DET_SERVER;
int ret = FAIL;
char args[2][MAX_STR_LENGTH] = {};
sls::strcpy_safe(args[0], fname.c_str());
sls::strcpy_safe(args[1], hostname.c_str());
FILE_LOG(logINFO) << "Sending detector server " << args[0] << " from host " << args[1];
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname, detector_shm()->controlPort);
ret = client.sendCommandThenRead(fnum, args, sizeof(args), nullptr, 0);
}
return ret;
}
int slsDetector::rebootController() {
if (detector_shm()->myDetectorType == EIGER) {
throw RuntimeError("Reboot controller not implemented for this detector");
}
int fnum = F_REBOOT_CONTROLLER;
int ret = FAIL;
FILE_LOG(logINFO) << "Sending reboot controller to detector " << detId << " (" << detector_shm()->hostname << ")";
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
auto client = DetectorSocket(detector_shm()->hostname, detector_shm()->controlPort);
client.sendData(&fnum, sizeof(fnum));
ret = OK;
}
return ret;
}
int slsDetector::powerChip(int ival) { int slsDetector::powerChip(int ival) {
int fnum = F_POWER_CHIP; int fnum = F_POWER_CHIP;
int ret = FAIL; int ret = FAIL;

View File

@ -405,6 +405,27 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced; descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
++i; ++i;
/*! \page config
- <b>copydetectorserver [sname] [phost]</b> copies the detector server sname via tftp from pc with hostname phost and changes respawn server for all detector. Not for Eiger. Only put! \c Returns \c ("successful", "failed")
*/
descrToFuncMap[i].m_pFuncName = "copydetectorserver";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
++i;
/*! \page config
- <b>rebootdetpc </b> reboot detector controller blackfin. Only put! Not for Eiger. \c Returns \c ("successful", "failed")
*/
descrToFuncMap[i].m_pFuncName = "rebootcontroller";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
++i;
/*! \page config
- <b>update [sname] [phost] [file] </b> updates the firmware to file and detector server to sname from phost via tftp and then reboots controller (blackfin). Only put! Not for Eiger. \c Returns \c ("successful", "failed")
*/
descrToFuncMap[i].m_pFuncName = "update";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdAdvanced;
++i;
/* chip */ /* chip */
/*! \page config /*! \page config
\section configchip Chip \section configchip Chip
@ -4753,9 +4774,6 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action,
if (strstr(args[1], ".pof") == nullptr) if (strstr(args[1], ".pof") == nullptr)
return std::string("wrong usage: programming file should have .pof extension"); return std::string("wrong usage: programming file should have .pof extension");
std::string sval = std::string(args[1]); std::string sval = std::string(args[1]);
#ifdef VERBOSE
std::cout << " programming file " << sval << std::endl;
#endif
myDet->setOnline(ONLINE_FLAG, detPos); myDet->setOnline(ONLINE_FLAG, detPos);
if (myDet->programFPGA(sval, detPos) == OK) if (myDet->programFPGA(sval, detPos) == OK)
return std::string("successful"); return std::string("successful");
@ -4765,15 +4783,51 @@ std::string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action,
else if (cmd == "resetfpga") { else if (cmd == "resetfpga") {
if (action == GET_ACTION) if (action == GET_ACTION)
return std::string("cannot get"); return std::string("cannot get");
#ifdef VERBOSE
std::cout << " resetting fpga " << std::endl;
#endif
myDet->setOnline(ONLINE_FLAG, detPos); myDet->setOnline(ONLINE_FLAG, detPos);
if (myDet->resetFPGA(detPos) == OK) if (myDet->resetFPGA(detPos) == OK)
return std::string("successful"); return std::string("successful");
return std::string("failed"); return std::string("failed");
} }
else if (cmd == "copydetectorserver") {
if (action == GET_ACTION)
return std::string("cannot get");
if (narg < 3)
return ("wrong usage." + helpAdvanced(PUT_ACTION));
std::string sval = std::string(args[1]);
std::string pval = std::string(args[2]);
myDet->setOnline(ONLINE_FLAG, detPos);
if (myDet->copyDetectorServer(sval, pval, detPos) == OK)
return std::string("successful");
return std::string("failed");
}
else if (cmd == "rebootcontroller") {
if (action == GET_ACTION)
return std::string("cannot get");
myDet->setOnline(ONLINE_FLAG, detPos);
if (myDet->rebootController(detPos) == OK)
return std::string("successful");
return std::string("failed");
}
else if (cmd == "update") {
if (action == GET_ACTION)
return std::string("cannot get");
if (narg < 4)
return ("wrong usage." + helpAdvanced(PUT_ACTION));
// pof
if (strstr(args[3], ".pof") == nullptr)
return std::string("wrong usage: programming file should have .pof extension");
std::string sval = std::string(args[1]);
std::string pval = std::string(args[2]);
std::string fval = std::string(args[3]);
myDet->setOnline(ONLINE_FLAG, detPos);
if (myDet->update(sval, pval, fval, detPos) == OK)
return std::string("successful");
return std::string("failed");
}
else if (cmd == "powerchip") { else if (cmd == "powerchip") {
char ans[100]; char ans[100];
myDet->setOnline(ONLINE_FLAG, detPos); myDet->setOnline(ONLINE_FLAG, detPos);
@ -4842,7 +4896,9 @@ std::string slsDetectorCommand::helpAdvanced(int action) {
os << "programfpga f \t programs the fpga with file f (with .pof extension)." << std::endl; os << "programfpga f \t programs the fpga with file f (with .pof extension)." << std::endl;
os << "resetfpga f \t resets fpga, f can be any value" << std::endl; os << "resetfpga f \t resets fpga, f can be any value" << std::endl;
os << "copydetectorserver s p \t copies the detector server s via tftp from pc with hostname p and changes respawn server. Not for Eiger. " << std::endl;
os << "rebootcontroller \t reboot controler blackfin of the detector. Not for Eiger." << std::endl;
os << "update s p f \t updates the firmware to f and detector server to f from host p via tftp and then reboots controller (blackfin). Not for Eiger. " << std::endl;
os << "led s \t sets led status (0 off, 1 on)" << std::endl; os << "led s \t sets led status (0 off, 1 on)" << std::endl;
os << "diodelay m v \tsets the delay for the digital IO pins selected by mask m and delay set by v. mask is upto 64 bits in hex, delay max is 775ps, and set in steps of 25 ps. Used for MOENCH/CTB only." << std::endl; os << "diodelay m v \tsets the delay for the digital IO pins selected by mask m and delay set by v. mask is upto 64 bits in hex, delay max is 775ps, and set in steps of 25 ps. Used for MOENCH/CTB only." << std::endl;
os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl; os << "powerchip i \t powers on or off the chip. i = 1 for on, i = 0 for off" << std::endl;

View File

@ -31,8 +31,8 @@ class MacAddr {
constexpr MacAddr(uint64_t mac) noexcept : addr_{mac} {} constexpr MacAddr(uint64_t mac) noexcept : addr_{mac} {}
MacAddr(std::string mac); MacAddr(std::string mac);
MacAddr(const char *address); MacAddr(const char *address);
std::string str() const { return to_hex(':'); } std::string str() const;
std::string hex() const { return to_hex(); } std::string hex() const;
constexpr bool operator==(const MacAddr &other) const noexcept { return addr_ == other.addr_; } constexpr bool operator==(const MacAddr &other) const noexcept { return addr_ == other.addr_; }
constexpr bool operator!=(const MacAddr &other) const noexcept { return addr_ != other.addr_; } constexpr bool operator!=(const MacAddr &other) const noexcept { return addr_ != other.addr_; }
constexpr bool operator==(const uint64_t other) const noexcept { return addr_ == other; } constexpr bool operator==(const uint64_t other) const noexcept { return addr_ == other; }

View File

@ -74,6 +74,8 @@ enum detFuncs{
F_SOFTWARE_TRIGGER,/** < software trigger */ F_SOFTWARE_TRIGGER,/** < software trigger */
F_LED, /** < switch on/off led */ F_LED, /** < switch on/off led */
F_DIGITAL_IO_DELAY, /** < digital IO delay */ F_DIGITAL_IO_DELAY, /** < digital IO delay */
F_COPY_DET_SERVER, /** < copy detector server & respawn */
F_REBOOT_CONTROLLER, /** < reboot detector controller (blackfin/ powerpc) */
NUM_DET_FUNCTIONS, NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 128, /**< detector function should not exceed this (detector server should not compile anyway) */ RECEIVER_ENUM_START = 128, /**< detector function should not exceed this (detector server should not compile anyway) */

View File

@ -19,7 +19,11 @@ namespace sls {
IpAddr::IpAddr(const std::string &address) { IpAddr::IpAddr(const std::string &address) {
inet_pton(AF_INET, address.c_str(), &addr_); inet_pton(AF_INET, address.c_str(), &addr_);
} }
IpAddr::IpAddr(const char *address) { inet_pton(AF_INET, address, &addr_); }
IpAddr::IpAddr(const char *address) {
inet_pton(AF_INET, address, &addr_);
}
std::string IpAddr::str() const { std::string IpAddr::str() const {
char ipstring[INET_ADDRSTRLEN]{}; char ipstring[INET_ADDRSTRLEN]{};
inet_ntop(AF_INET, &addr_, ipstring, INET_ADDRSTRLEN); inet_ntop(AF_INET, &addr_, ipstring, INET_ADDRSTRLEN);
@ -57,6 +61,14 @@ std::string MacAddr::to_hex(const char delimiter) const {
return ss.str(); return ss.str();
} }
std::string MacAddr::str() const {
return to_hex(':');
}
std::string MacAddr::hex() const {
return to_hex();
}
std::ostream &operator<<(std::ostream &out, const IpAddr &addr) { std::ostream &operator<<(std::ostream &out, const IpAddr &addr) {
return out << addr.str(); return out << addr.str();
} }