mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
Readlink (#117)
* gotthard config file path using readlink * gotthard2 * eiger * eieger, mnythen3, moench * binaries in * moved readlink to a common function * binaries in
This commit is contained in:
parent
beb6afe101
commit
ad297e9c51
Binary file not shown.
Binary file not shown.
@ -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"));
|
||||
|
Binary file not shown.
@ -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",
|
||||
|
Binary file not shown.
@ -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));
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
@ -3,7 +3,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int loadDefaultPattern(char *fname);
|
||||
int loadDefaultPattern(char *patFname);
|
||||
|
||||
int default_writePatternWord(char *line, uint32_t addr, uint64_t word);
|
||||
|
||||
|
@ -2,6 +2,10 @@
|
||||
#include "clogger.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <libgen.h> // dirname
|
||||
#include <unistd.h> // 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;
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
#include "clogger.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user