diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 0052bfdd6..c0a81fac7 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index 3912074c0..f8e9b9bbe 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index f8137d4a4..60bf508c9 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index d1891609c..6f96e3b10 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index a3892b752..a0598ad65 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index 8e767afa9..a72bdf234 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index ceb02a2b5..59c31180c 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/slsDetectorServer/include/common.h b/slsDetectorServers/slsDetectorServer/include/common.h index 8ce4be572..67e038279 100644 --- a/slsDetectorServers/slsDetectorServer/include/common.h +++ b/slsDetectorServers/slsDetectorServer/include/common.h @@ -47,4 +47,6 @@ int verifyChecksumFromFlash(char *mess, char *functionType, char *clientChecksum, char *fname, ssize_t fsize); int verifyChecksum(char *mess, char *functionType, char *clientChecksum, MD5_CTX *c, char *msg); -int setupDetectorServer(char *mess, char *sname); \ No newline at end of file +int setupDetectorServer(char *mess, char *sname); + +int writeBinaryFile(char* mess, char* fname, char* buffer, uint64_t filesize); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/common.c b/slsDetectorServers/slsDetectorServer/src/common.c index 2a609d60c..f0009bf7a 100644 --- a/slsDetectorServers/slsDetectorServer/src/common.c +++ b/slsDetectorServers/slsDetectorServer/src/common.c @@ -493,4 +493,27 @@ int setupDetectorServer(char *mess, char *sname) { } LOG(logINFO, ("\tsync\n")); return OK; +} + +int writeBinaryFile(char* mess, char* fname, char* buffer, uint64_t filesize) { + FILE *fp = fopen(fname, "wb"); + if (fp == NULL) { + sprintf(mess, "Could not copy detector server. (writing to file)\n"); + LOG(logERROR, (mess)); + return FAIL; + } + + size_t bytesWritten = fwrite(buffer, 1, filesize, fp); + if (bytesWritten != (size_t)filesize) { + sprintf(mess, "Could not copy detector server. Expected to write %lu bytes, wrote %lu bytes)\n", (long unsigned int)filesize, (long unsigned int)bytesWritten); + LOG(logERROR, (mess)); + return FAIL; + } + if (fclose(fp) != 0) { + sprintf(mess, "Could not copy detector server. (closing file pointer)\n"); + LOG(logERROR, (mess)); + return FAIL; + } + LOG(logINFO, ("\tWritten server binary to %s (%lu bytes)\n", fname, (long unsigned int)bytesWritten)); + return OK; } \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 72c8defa9..64d6fdb57 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -9381,7 +9381,10 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index, totalsize); break; case PROGRAM_SERVER: - ret = setupDetectorServer(mess, serverName); + ret = writeBinaryFile(mess, serverName, src, filesize); + if (ret == OK) { + ret = setupDetectorServer(mess, serverName); + } break; default: modeNotImplemented("Program index", (int)index); @@ -9454,22 +9457,27 @@ void receive_program_default(int file_des, enum PROGRAM_INDEX index, return; } -#if defined(GOTTHARD2D) || defined(MYTHEN3D) // appropriate functions switch (index) { +#if defined(GOTTHARD2D) || defined(MYTHEN3D) case PROGRAM_FPGA: case PROGRAM_KERNEL: ret = eraseAndWriteToFlash(mess, index, functionType, checksum, src, filesize); break; +#endif +#if defined(GOTTHARD2D) || defined(MYTHEN3D) || defined(EIGERD) case PROGRAM_SERVER: - ret = setupDetectorServer(mess, serverName); + ret = writeBinaryFile(mess, serverName, src, filesize); + if (ret == OK) { + ret = setupDetectorServer(mess, serverName); + } break; +#endif default: modeNotImplemented("Program index", (int)index); break; } -#endif // send result Server_SendResult(file_des, INT32, NULL, 0); diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 1a1fe7119..de0559d37 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -2534,6 +2534,7 @@ void Module::updateDetectorServer(std::vector buffer, break; case MYTHEN3: case GOTTHARD2: + case EIGER: sendProgram(false, buffer, F_UPDATE_DETECTOR_SERVER, "Update Detector Server (no tftp)", serverName); break;