diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index a16448fe4..12064d53c 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 5142d8e06..b3591ab0f 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 13ebfb71c..fdb2d7291 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -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) { diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index cea12ad76..9ea7f2213 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -1241,7 +1241,7 @@ int DetectorImpl::kbhit() { } std::vector 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 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"); } diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 92e6c4c99..db63991ce 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -3477,7 +3477,7 @@ void Module::programFPGAviaBlackfin(std::vector 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 buffer) { strcpy(cChecksum, checksum.c_str()); client.Send(cChecksum); + // validate file size before sending program if (client.Receive() == FAIL) { std::ostringstream os; os << "Detector " << moduleIndex << " (" << shm()->hostname << ")" @@ -3540,6 +3541,49 @@ void Module::programFPGAviaNios(std::vector 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( + (static_cast(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( + (static_cast(ERASE_TIME - count) / ERASE_TIME) * 100)); + std::cout << std::flush; + } + printf("\n"); + } if (client.Receive() == FAIL) { std::ostringstream os; os << "Detector " << moduleIndex << " (" << shm()->hostname << ")" @@ -3547,6 +3591,6 @@ void Module::programFPGAviaNios(std::vector buffer) { throw RuntimeError(os.str()); } LOG(logINFO) << "FPGA programmed successfully"; - rebootController(); + //rebootController(); } } // namespace sls diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index f2ca9f43a..d68d0b231 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -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