This commit is contained in:
maliakal_d 2021-09-03 15:15:39 +02:00
parent 2ef3dac39e
commit c3a26fdcaf

View File

@ -1266,7 +1266,6 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
<< "Updating Firmware. This can take awhile. Please be patient..."; << "Updating Firmware. This can take awhile. Please be patient...";
LOG(logDEBUG1) << "Programming FPGA with file name:" << fname; LOG(logDEBUG1) << "Programming FPGA with file name:" << fname;
size_t filesize = 0;
// check if it exists // check if it exists
struct stat st; struct stat st;
if (stat(fname.c_str(), &st) != 0) { if (stat(fname.c_str(), &st) != 0) {
@ -1294,6 +1293,7 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
// convert src to dst rawbin // convert src to dst rawbin
LOG(logDEBUG1) << "Converting " << fname << " to " << destfname; LOG(logDEBUG1) << "Converting " << fname << " to " << destfname;
LOG(logINFO) << "Converting program to rawbin";
{ {
constexpr int pofNumHeaderBytes = 0x11C; constexpr int pofNumHeaderBytes = 0x11C;
constexpr int pofFooterOfst = 0x1000000; constexpr int pofFooterOfst = 0x1000000;
@ -1314,14 +1314,17 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
// Swap bits from source and write to dest // Swap bits from source and write to dest
while (!feof(src)) { while (!feof(src)) {
// print progress // print progress
LOG(logINFO) << "Converting program to rawbin"; if (isPof) {
printf("%d%%\r", printf("pofFooterOfst:%d, dstfilepos:%d %d%%\r", pofFooterOfst,
(int)(((double)(pofFooterOfst - dstFilePos) / pofFooterOfst) * dstFilePos,
100)); (int)(((double)(pofFooterOfst - dstFilePos) /
fflush(stdout); pofFooterOfst) *
// pof: exit early to discard footer 100));
if (isPof && dstFilePos >= pofFooterOfst) { fflush(stdout);
break; // pof: exit early to discard footer
if (dstFilePos >= pofFooterOfst) {
break;
}
} }
// read source // read source
int s = fgetc(src); int s = fgetc(src);
@ -1358,7 +1361,7 @@ std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
if (fseek(fp, 0, SEEK_END) != 0) { if (fseek(fp, 0, SEEK_END) != 0) {
throw RuntimeError("Program FPGA: Seek error in rawbin file"); throw RuntimeError("Program FPGA: Seek error in rawbin file");
} }
filesize = ftell(fp); size_t filesize = ftell(fp);
if (filesize <= 0) { if (filesize <= 0) {
throw RuntimeError("Program FPGA: Could not get length of rawbin file"); throw RuntimeError("Program FPGA: Could not get length of rawbin file");
} }