mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 15:00:02 +02:00
wip
This commit is contained in:
parent
8f26389348
commit
441fb8064f
Binary file not shown.
@ -45,5 +45,6 @@ int startWritingFPGAprogram(FILE **filefp);
|
|||||||
int stopWritingFPGAprogram(FILE *filefp);
|
int stopWritingFPGAprogram(FILE *filefp);
|
||||||
|
|
||||||
int startCopyingFPGAProgram(FILE **fd, uint64_t fsize, char *mess);
|
int startCopyingFPGAProgram(FILE **fd, uint64_t fsize, char *mess);
|
||||||
int writeFPGAProgram(uint64_t fsize, FILE *fd, char *src, char *msg,
|
int writeFPGAProgram(FILE *fd, char *src, uint64_t fsize, char *msg,
|
||||||
char *mess);
|
char *mess);
|
||||||
|
int verifyCheckSumofProgram(char* clientChecksum, char* mess);
|
||||||
|
@ -179,7 +179,7 @@ int startCopyingFPGAProgram(FILE **fd, uint64_t fsize, char *mess) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int writeFPGAProgram(uint64_t fsize, FILE *fd, char *src, char* msg, char* mess) {
|
int writeFPGAProgram(FILE *fd, char *src, uint64_t fsize, char* msg, char* mess) {
|
||||||
LOG(logDEBUG1,
|
LOG(logDEBUG1,
|
||||||
("%s [fsize:%lu,fd:%p,src:%p\n", msg, (long long unsigned int)fsize, (void *)fd, (void *)src));
|
("%s [fsize:%lu,fd:%p,src:%p\n", msg, (long long unsigned int)fsize, (void *)fd, (void *)src));
|
||||||
|
|
||||||
@ -192,3 +192,33 @@ int writeFPGAProgram(uint64_t fsize, FILE *fd, char *src, char* msg, char* mess)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int verifyCheckSumofProgram(char* clientChecksum, char* mess) {
|
||||||
|
LOG(logINFOBLUE, ("\tVerifying Checksum\n"));
|
||||||
|
|
||||||
|
// get checksum from copied file
|
||||||
|
char cmd[MAX_STR_LENGTH] = {0};
|
||||||
|
memset(cmd, 0, MAX_STR_LENGTH);
|
||||||
|
sprintf(cmd, "md5sum %s", TEMP_PROG_FILE_NAME);
|
||||||
|
char retvals[MAX_STR_LENGTH] = {0};
|
||||||
|
memset(retvals, 0, MAX_STR_LENGTH);
|
||||||
|
if (FAIL == executeCommand(cmd, retvals, logDEBUG1)) {
|
||||||
|
strcpy(mess, retvals);
|
||||||
|
// LOG(logERROR, (mess)); already printed in executecommand
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
char checksum[MAX_STR_LENGTH];
|
||||||
|
memset(checksum, 0, sizeof(checksum));
|
||||||
|
if (sscanf(retvals, "%s", checksum) != 1) {
|
||||||
|
sprintf(mess, "Could not get checksum of fpga program copied over");
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
// compare checksum
|
||||||
|
if (strcmp(clientChecksum, checksum)) {
|
||||||
|
sprintf(mess, "Checksum of copied fpga program does not match. Client checksum:%s, copied checksum:%s\n", clientChecksum, checksum);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("\tChecksum verified from copied program\n"));
|
||||||
|
return OK;
|
||||||
|
}
|
@ -3730,7 +3730,7 @@ int program_fpga(int file_des) {
|
|||||||
memset(checksum, 0, MAX_STR_LENGTH);
|
memset(checksum, 0, MAX_STR_LENGTH);
|
||||||
if (receiveData(file_des, checksum, MAX_STR_LENGTH, OTHER) < 0)
|
if (receiveData(file_des, checksum, MAX_STR_LENGTH, OTHER) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logINFOBLUE, ("checksum is: %s\n\n", checksum));
|
LOG(logDEBUG1, ("checksum is: %s\n\n", checksum));
|
||||||
|
|
||||||
// open file and allocate memory for part program
|
// open file and allocate memory for part program
|
||||||
FILE *fd = NULL;
|
FILE *fd = NULL;
|
||||||
@ -3746,15 +3746,20 @@ int program_fpga(int file_des) {
|
|||||||
}
|
}
|
||||||
Server_SendResult(file_des, INT32, NULL, 0);
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
|
if (src != NULL) {
|
||||||
|
free(src);
|
||||||
|
}
|
||||||
if (fd != NULL) {
|
if (fd != NULL) {
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
}
|
}
|
||||||
|
LOG(logERROR, ("Program FPGA FAIL1!\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// copying program part by part
|
// copying program part by part
|
||||||
uint64_t totalsize = filesize;
|
uint64_t totalsize = filesize;
|
||||||
while (ret != FAIL && filesize) {
|
while (ret == OK && filesize) {
|
||||||
uint64_t unitprogramsize = MAX_FPGAPROGRAMSIZE; // 2mb
|
uint64_t unitprogramsize = MAX_FPGAPROGRAMSIZE; // 2mb
|
||||||
if (unitprogramsize > filesize) // less than 2mb
|
if (unitprogramsize > filesize) // less than 2mb
|
||||||
unitprogramsize = filesize;
|
unitprogramsize = filesize;
|
||||||
@ -3776,7 +3781,7 @@ int program_fpga(int file_des) {
|
|||||||
filesize -= unitprogramsize;
|
filesize -= unitprogramsize;
|
||||||
|
|
||||||
// copy program
|
// copy program
|
||||||
ret = writeFPGAProgram(unitprogramsize, fd, src, "copy program to /var/tmp", mess);
|
ret = writeFPGAProgram(fd, src, unitprogramsize, "copy program to /var/tmp", mess);
|
||||||
Server_SendResult(file_des, INT32, NULL, 0);
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
break;
|
break;
|
||||||
@ -3787,15 +3792,23 @@ int program_fpga(int file_des) {
|
|||||||
(int)(((double)(totalsize - filesize) / totalsize) * 100)));
|
(int)(((double)(totalsize - filesize) / totalsize) * 100)));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
if (ret == FAIL) {
|
if (src != NULL) {
|
||||||
free(src);
|
free(src);
|
||||||
|
}
|
||||||
|
if (fd != NULL) {
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// checksum of copied program
|
||||||
|
if (ret == OK) {
|
||||||
|
ret = verifyCheckSumofProgram(checksum, mess);
|
||||||
|
}
|
||||||
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
|
||||||
|
if (ret == FAIL) {
|
||||||
LOG(logERROR, ("Program FPGA FAIL!\n"));
|
LOG(logERROR, ("Program FPGA FAIL!\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
free(src);
|
|
||||||
fclose(fd);
|
|
||||||
LOG(logINFO, ("\n\tCopying done\n"));
|
|
||||||
|
|
||||||
/* if (ret != FAIL) {
|
/* if (ret != FAIL) {
|
||||||
fpgasrc[totalsize] = '\0';
|
fpgasrc[totalsize] = '\0';
|
||||||
|
@ -1419,7 +1419,8 @@ std::string DetectorImpl::getMd5Checksum(const std::string &fname) {
|
|||||||
std::string(e.what()));
|
std::string(e.what()));
|
||||||
}
|
}
|
||||||
pclose(pipe);
|
pclose(pipe);
|
||||||
return result;
|
auto list = sls::split(result, ' ');
|
||||||
|
return list[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
sls::Result<int> DetectorImpl::getNumberofUDPInterfaces(Positions pos) const {
|
sls::Result<int> DetectorImpl::getNumberofUDPInterfaces(Positions pos) const {
|
||||||
|
@ -3418,7 +3418,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer,
|
|||||||
LOG(logDEBUG1) << "checksum:" << checksum;
|
LOG(logDEBUG1) << "checksum:" << checksum;
|
||||||
|
|
||||||
// send program from memory to detector
|
// send program from memory to detector
|
||||||
LOG(logINFO) << "Sending programming binary (from pof) to detector "
|
LOG(logINFO) << "Sending programming binary (from pof) to module "
|
||||||
<< moduleId << " (" << shm()->hostname << ")";
|
<< moduleId << " (" << shm()->hostname << ")";
|
||||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||||
client.Send(F_PROGRAM_FPGA);
|
client.Send(F_PROGRAM_FPGA);
|
||||||
@ -3440,7 +3440,6 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer,
|
|||||||
// sending program in parts of 2mb each
|
// sending program in parts of 2mb each
|
||||||
uint64_t unitprogramsize = 0;
|
uint64_t unitprogramsize = 0;
|
||||||
int currentPointer = 0;
|
int currentPointer = 0;
|
||||||
uint64_t totalsize = filesize;
|
|
||||||
while (filesize > 0) {
|
while (filesize > 0) {
|
||||||
unitprogramsize = MAX_FPGAPROGRAMSIZE; // 2mb
|
unitprogramsize = MAX_FPGAPROGRAMSIZE; // 2mb
|
||||||
if (unitprogramsize > filesize) { // less than 2mb
|
if (unitprogramsize > filesize) { // less than 2mb
|
||||||
@ -3461,6 +3460,13 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer,
|
|||||||
currentPointer += unitprogramsize;
|
currentPointer += unitprogramsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checksum
|
||||||
|
if (client.Receive<int>() == FAIL) {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << "Detector " << moduleId << " (" << shm()->hostname << ")"
|
||||||
|
<< " returned error: " << client.readErrorMessage();
|
||||||
|
throw RuntimeError(os.str());
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
// error in detector at opening file pointer to flash
|
// error in detector at opening file pointer to flash
|
||||||
if (client.Receive<int>() == FAIL) {
|
if (client.Receive<int>() == FAIL) {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#define APICTB 0x210901
|
#define APICTB 0x210901
|
||||||
#define APIGOTTHARD 0x210901
|
#define APIGOTTHARD 0x210901
|
||||||
#define APIGOTTHARD2 0x210901
|
#define APIGOTTHARD2 0x210901
|
||||||
#define APIJUNGFRAU 0x210901
|
|
||||||
#define APIMYTHEN3 0x210901
|
#define APIMYTHEN3 0x210901
|
||||||
#define APIMOENCH 0x210901
|
#define APIMOENCH 0x210901
|
||||||
#define APIEIGER 0x210901
|
#define APIEIGER 0x210901
|
||||||
|
#define APIJUNGFRAU 0x210906
|
||||||
|
Loading…
x
Reference in New Issue
Block a user