diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 7d9d31a3f..191a400d7 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index 146dce365..d90f8d32a 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c index 25fa60526..a673a4081 100644 --- a/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c @@ -425,7 +425,14 @@ int readConfigFile() { } master = -1; top = -1; - FILE *fd = fopen(CONFIG_FILE, "r"); + + char fname[128]; + if (getAbsPath(fname, 128, CONFIG_FILE) == FAIL) { + return FAIL; + } + + // open config file + FILE *fd = fopen(fname, "r"); if (fd == NULL) { LOG(logINFO, ("No config file found. Resetting to hardware settings " "(Top/Master)\n")); diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index a0bdbfac3..7bd44559f 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index 662b8a9f7..2e9747145 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -485,7 +485,13 @@ int readConfigFile() { usleep(INITIAL_STARTUP_WAIT); - FILE *fd = fopen(CONFIG_FILE, "r"); + char fname[128]; + if (getAbsPath(fname, 128, CONFIG_FILE) == FAIL) { + return FAIL; + } + + // open config file + FILE *fd = fopen(fname, "r"); if (fd == NULL) { sprintf(initErrorMessage, "Could not open on-board detector server config file [%s].\n", diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index d71cd1f90..0e39bf69c 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index 4f1133d6c..262c7eef8 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -3,6 +3,7 @@ #include "clogger.h" #include "sharedMemory.h" #include "versionAPI.h" +#include "common.h" #include "LTC2620.h" // dacs #ifdef VIRTUAL @@ -577,10 +578,15 @@ void setGbitReadout() { } int readConfigFile() { + char fname[128]; + if (getAbsPath(fname, 128, CONFIG_FILE) == FAIL) { + return FAIL; + } + // open config file - FILE *fd = fopen(CONFIG_FILE, "r"); + FILE *fd = fopen(fname, "r"); if (fd == NULL) { - LOG(logWARNING, ("\tCould not find config file %s\n", CONFIG_FILE)); + LOG(logWARNING, ("Could not find config file %s\n", CONFIG_FILE)); return FAIL; } LOG(logINFO, ("\tConfig file %s opened\n", CONFIG_FILE)); diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index bef4195af..5b3f0f6b2 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index e8a16b655..9e6828a5f 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 785286507..ce42d4731 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/slsDetectorServer/include/common.h b/slsDetectorServers/slsDetectorServer/include/common.h index 0c4e4a95c..e4f009c48 100644 --- a/slsDetectorServers/slsDetectorServer/include/common.h +++ b/slsDetectorServers/slsDetectorServer/include/common.h @@ -1,5 +1,8 @@ #pragma once +#include + + /** * Convert a value from a range to a different range (eg voltage to dac or vice * versa) @@ -13,3 +16,7 @@ */ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int outputMax, int inputValue, int *outputValue); + + + +int getAbsPath(char* buf, size_t bufSize, char* fname); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/include/readDefaultPattern.h b/slsDetectorServers/slsDetectorServer/include/readDefaultPattern.h index 74bd32aa4..b9ee36a17 100644 --- a/slsDetectorServers/slsDetectorServer/include/readDefaultPattern.h +++ b/slsDetectorServers/slsDetectorServer/include/readDefaultPattern.h @@ -3,7 +3,7 @@ #include #include -int loadDefaultPattern(char *fname); +int loadDefaultPattern(char *patFname); int default_writePatternWord(char *line, uint32_t addr, uint64_t word); diff --git a/slsDetectorServers/slsDetectorServer/src/common.c b/slsDetectorServers/slsDetectorServer/src/common.c index b269f754e..621fc40af 100644 --- a/slsDetectorServers/slsDetectorServer/src/common.c +++ b/slsDetectorServers/slsDetectorServer/src/common.c @@ -2,6 +2,10 @@ #include "clogger.h" #include "sls_detector_defs.h" +#include +#include // dirname +#include // readlink + int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int outputMax, int inputValue, int *outputValue) { LOG(logDEBUG1, (" Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n", @@ -37,3 +41,23 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, LOG(logDEBUG1, (" Converted Output Value: %d\n", *outputValue)); return OK; } + + +int getAbsPath(char* buf, size_t bufSize, char* fname) { + // get path of current binary + char path[bufSize]; + memset(path, 0, bufSize); + ssize_t len = readlink("/proc/self/exe", path, bufSize - 1); + if (len < 0) { + LOG(logWARNING, ("Could not readlink current binary for %s\n", fname)); + return FAIL; + } + path[len] = '\0'; + + // get dir path and attach config file name + char *dir = dirname(path); + memset(buf, 0, bufSize); + sprintf(buf, "%s/%s", dir, fname); + LOG(logDEBUG1, ("full path for %s: %s\n", fname, buf)); + return OK; +} \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c b/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c index e4557958c..25f6a5744 100644 --- a/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c +++ b/slsDetectorServers/slsDetectorServer/src/readDefaultPattern.c @@ -3,6 +3,7 @@ #include "clogger.h" #include "slsDetectorServer_defs.h" #include "sls_detector_defs.h" +#include "common.h" #include @@ -18,19 +19,26 @@ extern uint64_t setPatternWaitTime(int level, uint64_t t); extern void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop); -int loadDefaultPattern(char *fname) { +int loadDefaultPattern(char *patFname) { if (initError == FAIL) { return initError; } + char fname[128]; + if (getAbsPath(fname, 128, patFname) == FAIL) { + return FAIL; + } + + // open config file FILE *fd = fopen(fname, "r"); if (fd == NULL) { - sprintf(initErrorMessage, "Could not open pattern file [%s].\n", fname); + sprintf(initErrorMessage, "Could not open pattern file [%s].\n", + patFname); initError = FAIL; LOG(logERROR, ("%s\n\n", initErrorMessage)); return FAIL; } - LOG(logINFOBLUE, ("Reading default pattern file %s\n", fname)); + LOG(logINFOBLUE, ("Reading default pattern file %s\n", patFname)); // Initialization const size_t LZ = 256; diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index 584ef056c..357d3fd69 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -3,10 +3,10 @@ #define APILIB 0x200409 #define APIRECEIVER 0x200409 #define APIGUI 0x200409 -#define APICTB 0x200720 -#define APIGOTTHARD 0x200720 -#define APIJUNGFRAU 0x200720 -#define APIMYTHEN3 0x200720 -#define APIMOENCH 0x200720 -#define APIEIGER 0x200720 -#define APIGOTTHARD2 0x200722 +#define APICTB 0x200723 +#define APIGOTTHARD 0x200723 +#define APIGOTTHARD2 0x200723 +#define APIJUNGFRAU 0x200723 +#define APIMYTHEN3 0x200723 +#define APIMOENCH 0x200722 +#define APIEIGER 0x200723