mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-11 15:20:01 +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
|
// receive program
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
char *fpgasrc = malloc(filesize);
|
char *fpgasrc = malloc(filesize);
|
||||||
if (receiveData(file_des, fpgasrc, filesize, OTHER) < 0)
|
if (receiveData(file_des, fpgasrc, filesize, OTHER) < 0) {
|
||||||
|
free(fpgasrc);
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
}
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
ret = eraseAndWriteToFlash(mess, checksum, fpgasrc, filesize);
|
ret = eraseAndWriteToFlash(mess, checksum, fpgasrc, filesize);
|
||||||
#endif
|
#endif
|
||||||
Server_SendResult(file_des, INT32, NULL, 0);
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
|
||||||
// free resources
|
|
||||||
free(fpgasrc);
|
free(fpgasrc);
|
||||||
}
|
}
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
|
@ -1241,7 +1241,7 @@ int DetectorImpl::kbhit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
||||||
/* // validate type of file
|
// validate type of file
|
||||||
bool isPof = false;
|
bool isPof = false;
|
||||||
switch (multi_shm()->multiDetectorType) {
|
switch (multi_shm()->multiDetectorType) {
|
||||||
case JUNGFRAU:
|
case JUNGFRAU:
|
||||||
@ -1361,9 +1361,10 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
|
|||||||
throw RuntimeError("Program FPGA: Could not close destination file");
|
throw RuntimeError("Program FPGA: Could not close destination file");
|
||||||
}
|
}
|
||||||
LOG(logINFOBLUE) << "File has been converted to " << destfname;
|
LOG(logINFOBLUE) << "File has been converted to " << destfname;
|
||||||
*/
|
|
||||||
// loading dst file to memory
|
// 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) {
|
if (fp == nullptr) {
|
||||||
throw RuntimeError("Program FPGA: Could not open rawbin file");
|
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 << " ("
|
LOG(logINFO) << "Checksum verified for module " << moduleIndex << " ("
|
||||||
<< shm()->hostname << ")";
|
<< shm()->hostname << ")";
|
||||||
|
|
||||||
// erasing flash
|
// simulating erasing flash
|
||||||
{
|
{
|
||||||
LOG(logINFO) << "Erasing Flash for module " << moduleIndex << " ("
|
LOG(logINFO) << "Erasing Flash for module " << moduleIndex << " ("
|
||||||
<< shm()->hostname << ")";
|
<< shm()->hostname << ")";
|
||||||
@ -3533,6 +3533,7 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
|||||||
strcpy(cChecksum, checksum.c_str());
|
strcpy(cChecksum, checksum.c_str());
|
||||||
client.Send(cChecksum);
|
client.Send(cChecksum);
|
||||||
|
|
||||||
|
// validate file size before sending program
|
||||||
if (client.Receive<int>() == FAIL) {
|
if (client.Receive<int>() == FAIL) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
||||||
@ -3540,6 +3541,49 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
|||||||
throw RuntimeError(os.str());
|
throw RuntimeError(os.str());
|
||||||
}
|
}
|
||||||
client.Send(buffer);
|
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) {
|
if (client.Receive<int>() == FAIL) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
||||||
@ -3547,6 +3591,6 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
|||||||
throw RuntimeError(os.str());
|
throw RuntimeError(os.str());
|
||||||
}
|
}
|
||||||
LOG(logINFO) << "FPGA programmed successfully";
|
LOG(logINFO) << "FPGA programmed successfully";
|
||||||
rebootController();
|
//rebootController();
|
||||||
}
|
}
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#define APICTB 0x210909
|
#define APICTB 0x210909
|
||||||
#define APIGOTTHARD 0x210909
|
#define APIGOTTHARD 0x210909
|
||||||
#define APIGOTTHARD2 0x210909
|
|
||||||
#define APIJUNGFRAU 0x210909
|
|
||||||
#define APIMYTHEN3 0x210909
|
#define APIMYTHEN3 0x210909
|
||||||
#define APIMOENCH 0x210909
|
#define APIMOENCH 0x210909
|
||||||
#define APIEIGER 0x210909
|
#define APIEIGER 0x210909
|
||||||
|
#define APIJUNGFRAU 0x210913
|
||||||
|
#define APIGOTTHARD2 0x210914
|
||||||
|
Loading…
x
Reference in New Issue
Block a user