mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-07-12 19:01:50 +02:00
Dev/xilinx mat update (#959)
* put back code to obtain adc and dac device indexafter loading device tree and then create folder iio_device_links and create symbolic links there according to device indices found. ln -sf operation not permitted, so folder has to be deleted and created everytime. Also refactored definitions to have all the xilinx name or detector specific stuff out of programbyArm.c * uncommented waittransceiverreset at startup (should work now) and return of powering off chip at startup (error for transceiver alignment reset) * updated registerdefs from firmware * minor prints and updating names from registerdefs * waittransceiverreset has been fixed in firmware and removing warnign for that, transceiver alignment check for powering off chip is not done in fw (giving a warning and returning ok for now) * fixing ipchecksum (not done), removed startperiphery, allowing readout command to be allowed for xilinx when acquiring
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
|
||||
#include <libgen.h> // dirname
|
||||
#include <string.h>
|
||||
#include <sys/stat.h> // stat
|
||||
#include <sys/utsname.h> // uname
|
||||
#include <unistd.h> // readlink
|
||||
|
||||
@ -677,31 +678,7 @@ int deleteFile(char *mess, char *fname, char *errorPrefix) {
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (access(fullname, F_OK) == 0) {
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "rm %s", fullname) >=
|
||||
MAX_STR_LENGTH) {
|
||||
sprintf(mess, "Could not %s. Command to delete is too long\n",
|
||||
errorPrefix);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH,
|
||||
"Could not %s. (deleting file %s). %s\n", errorPrefix,
|
||||
fullname, retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tDeleted file: %s (%s)\n", fullname, errorPrefix));
|
||||
} else {
|
||||
LOG(logINFO,
|
||||
("\tFile does not exist anyway: %s (%s)\n", fullname, errorPrefix));
|
||||
}
|
||||
return OK;
|
||||
return deleteItem(mess, 1, fullname, errorPrefix);
|
||||
}
|
||||
|
||||
int deleteOldServers(char *mess, char *newServerPath, char *errorPrefix) {
|
||||
@ -758,4 +735,60 @@ int readParameterFromFile(char *fname, char *parameterName, int *value) {
|
||||
|
||||
fclose(fd);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int createAbsoluteDirectory(char *mess, const char *absPath,
|
||||
char *errorPrefix) {
|
||||
// check if folder exists
|
||||
if (access(absPath, F_OK) == 0) {
|
||||
LOG(logINFO, ("Folder %s already exists\n", absPath));
|
||||
return OK;
|
||||
}
|
||||
|
||||
// folder does not exist, create it
|
||||
if (mkdir(absPath, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
|
||||
sprintf(mess, "Could not %s. Could not create folder %s\n", errorPrefix,
|
||||
absPath);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tCreated folder: %s (%s)\n", absPath, errorPrefix));
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int deleteAbsoluteDirectory(char *mess, const char *absPath,
|
||||
char *errorPrefix) {
|
||||
return deleteItem(mess, 0, absPath, errorPrefix);
|
||||
}
|
||||
|
||||
int deleteItem(char *mess, int isFile, const char *absPath, char *errorPrefix) {
|
||||
// item does not exist
|
||||
if (access(absPath, F_OK) != 0) {
|
||||
LOG(logINFO, ("\t%s does not exist anyway: %s (%s)\n",
|
||||
(isFile ? "File" : "Folder"), absPath, errorPrefix));
|
||||
return OK;
|
||||
}
|
||||
|
||||
// delete item
|
||||
char cmd[MAX_STR_LENGTH] = {0};
|
||||
char retvals[MAX_STR_LENGTH] = {0};
|
||||
if (snprintf(cmd, MAX_STR_LENGTH, "rm %s %s", (isFile ? "-f" : "-rf"),
|
||||
absPath) >= MAX_STR_LENGTH) {
|
||||
sprintf(mess, "Could not %s. Command to delete is too long\n",
|
||||
errorPrefix);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||
snprintf(mess, MAX_STR_LENGTH, "Could not %s. (deleting %s %s). %s\n",
|
||||
errorPrefix, (isFile ? "file" : "folder"), absPath, retvals);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFO, ("\tDeleted %s: %s (%s)\n", (isFile ? "file" : "folder"),
|
||||
absPath, errorPrefix));
|
||||
|
||||
return OK;
|
||||
}
|
Reference in New Issue
Block a user