mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-02-02 19:04:58 +01:00
replaced old logger
This commit is contained in:
@@ -14,7 +14,7 @@ char mtdvalue[MTDSIZE] = {0};
|
||||
#define MICROCONTROLLER_FILE "/dev/ttyAL0"
|
||||
|
||||
void NotifyServerStartSuccess() {
|
||||
FILE_LOG(logINFOBLUE, ("Server started successfully\n"));
|
||||
LOG(logINFOBLUE, ("Server started successfully\n"));
|
||||
char command[255];
|
||||
memset(command, 0, 255);
|
||||
sprintf(command,"echo r > %s",MICROCONTROLLER_FILE);
|
||||
@@ -26,17 +26,17 @@ void CreateNotificationForCriticalTasks() {
|
||||
if (fd == NULL) {
|
||||
fd = fopen(NOTIFICATION_FILE, "w");
|
||||
if (fd == NULL) {
|
||||
FILE_LOG(logERROR, ("Could not create notication file: %s\n", NOTIFICATION_FILE));
|
||||
LOG(logERROR, ("Could not create notication file: %s\n", NOTIFICATION_FILE));
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logINFOBLUE, ("Created notification file: %s\n", NOTIFICATION_FILE));
|
||||
LOG(logINFOBLUE, ("Created notification file: %s\n", NOTIFICATION_FILE));
|
||||
}
|
||||
fclose(fd);
|
||||
NotifyCriticalTaskDone();
|
||||
}
|
||||
|
||||
void NotifyCriticalTask() {
|
||||
FILE_LOG(logINFO, ("\tNotifying Critical Task Ongoing\n"));
|
||||
LOG(logINFO, ("\tNotifying Critical Task Ongoing\n"));
|
||||
char command[255];
|
||||
memset(command, 0, 255);
|
||||
sprintf(command,"echo 1 > %s",NOTIFICATION_FILE);
|
||||
@@ -44,7 +44,7 @@ void NotifyCriticalTask() {
|
||||
}
|
||||
|
||||
void NotifyCriticalTaskDone() {
|
||||
FILE_LOG(logINFO, ("\tNotifying Critical Task Done\n"));
|
||||
LOG(logINFO, ("\tNotifying Critical Task Done\n"));
|
||||
char command[255];
|
||||
memset(command, 0, 255);
|
||||
sprintf(command,"echo 0 > %s",NOTIFICATION_FILE);
|
||||
@@ -52,7 +52,7 @@ void NotifyCriticalTaskDone() {
|
||||
}
|
||||
|
||||
void rebootControllerAndFPGA() {
|
||||
FILE_LOG(logDEBUG1, ("Reseting FPGA...\n"));
|
||||
LOG(logDEBUG1, ("Reseting FPGA...\n"));
|
||||
char command[255];
|
||||
memset(command, 0, 255);
|
||||
sprintf(command,"echo z > %s",MICROCONTROLLER_FILE);
|
||||
@@ -60,7 +60,7 @@ void rebootControllerAndFPGA() {
|
||||
}
|
||||
|
||||
int findFlash(char* mess) {
|
||||
FILE_LOG(logDEBUG1, ("Finding flash drive...\n"));
|
||||
LOG(logDEBUG1, ("Finding flash drive...\n"));
|
||||
//getting the drive
|
||||
// # cat /proc/mtd
|
||||
// dev: size erasesize name
|
||||
@@ -75,12 +75,12 @@ int findFlash(char* mess) {
|
||||
FILE* fp = popen("awk \'$5== \"Application\" {print $1}\' /proc/mtd", "r");
|
||||
if (fp == NULL) {
|
||||
strcpy(mess, "popen returned NULL. Need that to get mtd drive.\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
return RO_TRIGGER_IN_FALLING_EDGE;
|
||||
}
|
||||
if (fgets(output, sizeof(output), fp) == NULL) {
|
||||
strcpy(mess, "fgets returned NULL. Need that to get mtd drive.\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
pclose(fp);
|
||||
@@ -89,21 +89,21 @@ int findFlash(char* mess) {
|
||||
char* pch = strtok(output, ":");
|
||||
if (pch == NULL){
|
||||
strcpy (mess, "Could not get mtd value\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
strcat(mtdvalue, pch);
|
||||
FILE_LOG(logINFO, ("\tFlash drive found: %s\n", mtdvalue));
|
||||
LOG(logINFO, ("\tFlash drive found: %s\n", mtdvalue));
|
||||
return OK;
|
||||
}
|
||||
|
||||
void eraseFlash() {
|
||||
FILE_LOG(logDEBUG1, ("Erasing Flash...\n"));
|
||||
LOG(logDEBUG1, ("Erasing Flash...\n"));
|
||||
char command[255];
|
||||
memset(command, 0, 255);
|
||||
sprintf(command,"flash_erase %s 0 0",mtdvalue);
|
||||
system(command);
|
||||
FILE_LOG(logINFO, ("\tFlash erased\n"));
|
||||
LOG(logINFO, ("\tFlash erased\n"));
|
||||
}
|
||||
|
||||
int eraseAndWriteToFlash(char* mess, char* fpgasrc, uint64_t fsize) {
|
||||
@@ -118,10 +118,10 @@ int eraseAndWriteToFlash(char* mess, char* fpgasrc, uint64_t fsize) {
|
||||
if(filefp == NULL){
|
||||
NotifyCriticalTaskDone();
|
||||
sprintf (mess, "Unable to open %s in write mode\n", mtdvalue);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO, ("\tFlash ready for writing\n"));
|
||||
LOG(logINFO, ("\tFlash ready for writing\n"));
|
||||
|
||||
// write to flash
|
||||
if (writeFPGAProgram(mess, fpgasrc, fsize, filefp) == FAIL) {
|
||||
@@ -136,7 +136,7 @@ int eraseAndWriteToFlash(char* mess, char* fpgasrc, uint64_t fsize) {
|
||||
}
|
||||
|
||||
int writeFPGAProgram(char* mess, char* fpgasrc, uint64_t fsize, FILE* filefp) {
|
||||
FILE_LOG(logDEBUG1, ("Writing to flash...\n"
|
||||
LOG(logDEBUG1, ("Writing to flash...\n"
|
||||
"\taddress of fpgasrc:%p\n"
|
||||
"\tfsize:%lu\n\tpointer:%p\n",
|
||||
(void *)fpgasrc, fsize, (void*)filefp));
|
||||
@@ -144,9 +144,9 @@ int writeFPGAProgram(char* mess, char* fpgasrc, uint64_t fsize, FILE* filefp) {
|
||||
uint64_t retval = fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp);
|
||||
if (retval != fsize) {
|
||||
sprintf (mess, "Could not write FPGA source to flash (size:%llu), write %llu\n", (long long unsigned int) fsize, (long long unsigned int)retval);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO, ("\tProgram written to flash\n"));
|
||||
LOG(logINFO, ("\tProgram written to flash\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user