mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
actually writing the server binary from memory to file before linking, sycing, permissions etc
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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);
|
||||
int setupDetectorServer(char *mess, char *sname);
|
||||
|
||||
int writeBinaryFile(char* mess, char* fname, char* buffer, uint64_t filesize);
|
@ -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;
|
||||
}
|
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user