mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-09 14:20:03 +02:00
works for niosg
This commit is contained in:
parent
b2cb99a0c2
commit
0f8869153e
Binary file not shown.
Binary file not shown.
@ -3711,14 +3711,14 @@ int program_fpga(int file_des) {
|
||||
// receive program
|
||||
if (ret == OK) {
|
||||
char *fpgasrc = malloc(filesize);
|
||||
if (receiveData(file_des, fpgasrc, filesize, OTHER) < 0)
|
||||
if (receiveData(file_des, fpgasrc, filesize, OTHER) < 0) {
|
||||
free(fpgasrc);
|
||||
return printSocketReadError();
|
||||
}
|
||||
#ifndef VIRTUAL
|
||||
ret = eraseAndWriteToFlash(mess, checksum, fpgasrc, filesize);
|
||||
#endif
|
||||
Server_SendResult(file_des, INT32, NULL, 0);
|
||||
|
||||
// free resources
|
||||
free(fpgasrc);
|
||||
}
|
||||
if (ret == FAIL) {
|
||||
|
@ -1241,7 +1241,7 @@ int DetectorImpl::kbhit() {
|
||||
}
|
||||
|
||||
std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
||||
/* // validate type of file
|
||||
// validate type of file
|
||||
bool isPof = false;
|
||||
switch (multi_shm()->multiDetectorType) {
|
||||
case JUNGFRAU:
|
||||
@ -1361,9 +1361,10 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
||||
throw RuntimeError("Program FPGA: Could not close destination file");
|
||||
}
|
||||
LOG(logINFOBLUE) << "File has been converted to " << destfname;
|
||||
*/
|
||||
|
||||
// loading dst file to memory
|
||||
FILE *fp = fopen("/tmp/SLS_DET_MCB.tzgmUT", "r");
|
||||
// FILE *fp = fopen("/tmp/SLS_DET_MCB.tzgmUT", "r");
|
||||
FILE *fp = fopen(destfname, "r");
|
||||
if (fp == nullptr) {
|
||||
throw RuntimeError("Program FPGA: Could not open rawbin file");
|
||||
}
|
||||
|
@ -3477,7 +3477,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
LOG(logINFO) << "Checksum verified for module " << moduleIndex << " ("
|
||||
<< shm()->hostname << ")";
|
||||
|
||||
// erasing flash
|
||||
// simulating erasing flash
|
||||
{
|
||||
LOG(logINFO) << "Erasing Flash for module " << moduleIndex << " ("
|
||||
<< shm()->hostname << ")";
|
||||
@ -3533,6 +3533,7 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
||||
strcpy(cChecksum, checksum.c_str());
|
||||
client.Send(cChecksum);
|
||||
|
||||
// validate file size before sending program
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
@ -3540,6 +3541,49 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
client.Send(buffer);
|
||||
|
||||
// simulating erasing flash
|
||||
{
|
||||
LOG(logINFO) << "(Simulating) Erasing Flash for module " << moduleIndex << " ("
|
||||
<< shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
// erasing takes 10 seconds, printing here (otherwise need threads
|
||||
// in server-unnecessary)
|
||||
const int ERASE_TIME = 10;
|
||||
int count = ERASE_TIME + 1;
|
||||
while (count > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
--count;
|
||||
printf(
|
||||
"%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) * 100));
|
||||
std::cout << std::flush;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
// simulating writing to flash
|
||||
{
|
||||
LOG(logINFO) << "(Simulating) Writing to Flash for module " << moduleIndex << " (" << shm()->hostname << ")";
|
||||
printf("%d%%\r", 0);
|
||||
std::cout << std::flush;
|
||||
// writing takes 45 seconds, printing here (otherwise need threads
|
||||
// in server-unnecessary)
|
||||
const int ERASE_TIME = 45;
|
||||
int count = ERASE_TIME + 1;
|
||||
while (count > 0) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
--count;
|
||||
printf(
|
||||
"%d%%\r",
|
||||
static_cast<int>(
|
||||
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) * 100));
|
||||
std::cout << std::flush;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
@ -3547,6 +3591,6 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
LOG(logINFO) << "FPGA programmed successfully";
|
||||
rebootController();
|
||||
//rebootController();
|
||||
}
|
||||
} // namespace sls
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#define APICTB 0x210909
|
||||
#define APIGOTTHARD 0x210909
|
||||
#define APIGOTTHARD2 0x210909
|
||||
#define APIJUNGFRAU 0x210909
|
||||
#define APIMYTHEN3 0x210909
|
||||
#define APIMOENCH 0x210909
|
||||
#define APIEIGER 0x210909
|
||||
#define APIJUNGFRAU 0x210913
|
||||
#define APIGOTTHARD2 0x210914
|
||||
|
Loading…
x
Reference in New Issue
Block a user