This commit is contained in:
maliakal_d 2020-06-23 13:56:45 +02:00
parent 4cbe354396
commit 692ade6c17
3 changed files with 24 additions and 29 deletions

View File

@ -2894,9 +2894,9 @@ int set_pattern_word(int file_des) {
#else
int addr = (int)args[0];
uint64_t word = args[1];
if (word != (int64_t)-1) {
if (word != (uint64_t)-1) {
LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx\n", addr,
(long long int)word));
(long long int)word));
}
if (Server_VerifyLock() == OK) {
// valid address
@ -7340,7 +7340,7 @@ int set_veto(int file_des) {
int set_pattern(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
uint64_t* patwords = malloc(sizeof(uint64_t) * MAX_PATTERN_LENGTH);
uint64_t *patwords = malloc(sizeof(uint64_t) * MAX_PATTERN_LENGTH);
memset(patwords, 0, sizeof(uint64_t) * MAX_PATTERN_LENGTH);
uint64_t patioctrl = 0;
int patlimits[2] = {0, 0};
@ -7348,7 +7348,8 @@ int set_pattern(int file_des) {
int patnloop[3] = {0, 0, 0};
int patwait[3] = {0, 0, 0};
uint64_t patwaittime[3] = {0, 0, 0};
if (receiveData(file_des, patwords, sizeof(uint64_t) * MAX_PATTERN_LENGTH, INT64) < 0)
if (receiveData(file_des, patwords, sizeof(uint64_t) * MAX_PATTERN_LENGTH,
INT64) < 0)
return printSocketReadError();
if (receiveData(file_des, &patioctrl, sizeof(patioctrl), INT64) < 0)
return printSocketReadError();
@ -7368,12 +7369,12 @@ int set_pattern(int file_des) {
#else
if (Server_VerifyLock() == OK) {
LOG(logINFO, ("Setting Pattern from file\n"));
LOG(logINFO, ("Setting Pattern Word (printing every 10 words that are not 0\n"));
LOG(logINFO,
("Setting Pattern Word (printing every 10 words that are not 0\n"));
for (int i = 0; i < MAX_PATTERN_LENGTH; ++i) {
if ((i%10 == 0) && patwords[i] != 0) {
LOG(logINFO,
("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", i,
(long long int)patwords[i]));
if ((i % 10 == 0) && patwords[i] != 0) {
LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n",
i, (long long int)patwords[i]));
}
writePatternWord(i, patwords[i]);
}

View File

@ -1748,25 +1748,20 @@ void Module::setLEDEnable(bool enable) {
void Module::setPattern(const std::string &fname) {
patternParameters pat;
memset(&pat, 0, sizeof(pat));
std::ifstream input_file;
input_file.open(fname.c_str(), std::ios_base::in);
std::ifstream input_file(fname);
if (!input_file.is_open()) {
throw RuntimeError("Could not open pattern file " + fname +
" for reading");
}
std::string current_line;
while (input_file.good()) {
getline(input_file, current_line);
if (current_line.find('#') != std::string::npos) {
current_line.erase(current_line.find('#'));
for (std::string line; std::getline(input_file, line);) {
if (line.find('#') != std::string::npos) {
line.erase(line.find('#'));
}
LOG(logDEBUG1) << "current_line after removing comments:\n\t"
<< current_line;
if (current_line.length() > 1) {
LOG(logDEBUG1) << "line after removing comments:\n\t" << line;
if (line.length() > 1) {
// convert command and string to a vector
std::istringstream iss(current_line);
std::istringstream iss(line);
auto it = std::istream_iterator<std::string>(iss);
std::vector<std::string> args = std::vector<std::string>(
it, std::istream_iterator<std::string>());
@ -1848,7 +1843,6 @@ void Module::setPattern(const std::string &fname) {
}
}
}
input_file.close();
sendToDetector(F_SET_PATTERN, pat, nullptr);
}

View File

@ -442,13 +442,13 @@ typedef struct {
/** pattern structure */
struct patternParameters {
uint64_t word[MAX_PATTERN_LENGTH];
uint64_t patioctrl;
uint32_t patlimits[2];
uint32_t patloop[6];
uint32_t patnloop[3];
uint32_t patwait[3];
uint64_t patwaittime[3];
uint64_t word[MAX_PATTERN_LENGTH] = {};
uint64_t patioctrl{0};
uint32_t patlimits[2] = {};
uint32_t patloop[6] = {};
uint32_t patnloop[3] = {};
uint32_t patwait[3] = {};
uint64_t patwaittime[3] = {};
} __attribute__((packed));
#endif