diff --git a/slsDetectorServers/slsDetectorServer/include/programFpgaBlackfin.h b/slsDetectorServers/slsDetectorServer/include/programFpgaBlackfin.h index 500039c40..6b9434327 100644 --- a/slsDetectorServers/slsDetectorServer/include/programFpgaBlackfin.h +++ b/slsDetectorServers/slsDetectorServer/include/programFpgaBlackfin.h @@ -1,8 +1,8 @@ #pragma once +#include #include #include - /** * Define GPIO pins if not defined */ diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 4f94f8254..d7ff59e0b 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -10,6 +10,8 @@ #include "sls/sls_detector_funcs.h" #include "sls/string_utils.h" #include "sls/versionAPI.h" + + #include #include #include @@ -21,6 +23,7 @@ #include #include #include +#include namespace sls { @@ -3409,8 +3412,19 @@ sls_detector_module Module::readSettingsFile(const std::string &fname, return myMod; } +int Module::calculateChecksum(char *buffer, size_t bsize) { + unsigned char checksum = 0; + for(size_t i = 0; i != bsize; ++i)) { + checksum ^= fgetc(fp); + } + return 0; +} + void Module::programFPGAviaBlackfin(std::vector buffer) { + // calculate checksum uint64_t filesize = buffer.size(); + int checksum = calculateChecksum(&buffer[0], filesize); + LOG(logINFOBLUE) << "checksum:" << checksum; // send program from memory to detector LOG(logINFO) << "Sending programming binary (from pof) to detector " << moduleId << " (" << shm()->hostname << ")"; diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 715f9b533..f44d57223 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -744,6 +744,7 @@ class Module : public virtual slsDetectorDefs { std::string getTrimbitFilename(detectorSettings settings, int e_eV); sls_detector_module readSettingsFile(const std::string &fname, bool trimbits = true); + int calculateChecksum(char *buffer, size_t bsize); void programFPGAviaBlackfin(std::vector buffer); void programFPGAviaNios(std::vector buffer);