mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 21:37:13 +02:00
blackfin requires a few writes
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.
@ -49,4 +49,4 @@ int verifyChecksum(char *mess, char *functionType, char *clientChecksum,
|
||||
MD5_CTX *c, char *msg);
|
||||
int setupDetectorServer(char *mess, char *sname);
|
||||
|
||||
int writeBinaryFile(char* mess, char* fname, char* buffer, uint64_t filesize);
|
||||
int writeBinaryFile(char* mess, char* fname, char* buffer, const uint64_t filesize);
|
@ -495,7 +495,9 @@ int setupDetectorServer(char *mess, char *sname) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int writeBinaryFile(char* mess, char* fname, char* buffer, uint64_t filesize) {
|
||||
int writeBinaryFile(char* mess, char* fname, char* buffer, const uint64_t filesize) {
|
||||
LOG(logINFO, ("\tWriting Detector Server Binary...\n"));
|
||||
|
||||
FILE *fp = fopen(fname, "wb");
|
||||
if (fp == NULL) {
|
||||
sprintf(mess, "Could not copy detector server. (opening file to write(%s). Maybe it is being used? Try another server name?\n", fname);
|
||||
@ -503,12 +505,35 @@ int writeBinaryFile(char* mess, char* fname, char* buffer, uint64_t filesize) {
|
||||
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);
|
||||
size_t bytesWritten = 0;
|
||||
size_t unitSize = 128;
|
||||
int oldProgress = 0;
|
||||
|
||||
while (bytesWritten < filesize) {
|
||||
// print progress
|
||||
int progress = (int)(((double)(bytesWritten) / filesize) * 100);
|
||||
if (oldProgress != progress) {
|
||||
printf("%d%%\r", progress);
|
||||
fflush(stdout);
|
||||
oldProgress = progress;
|
||||
}
|
||||
|
||||
// for less than 128 bytes
|
||||
ssize_t writeSize = unitSize;
|
||||
if ((unitSize + bytesWritten) > filesize) {
|
||||
writeSize = filesize - bytesWritten;
|
||||
}
|
||||
size_t bytes = fwrite(buffer, 1, writeSize, fp);
|
||||
|
||||
// write
|
||||
if (bytes != (size_t)writeSize) {
|
||||
sprintf(mess, "Could not copy detector server. Expected to write %lu bytes, wrote %lu bytes). No space left? \n", (long unsigned int)filesize, (long unsigned int)bytesWritten);
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
bytesWritten += bytes;
|
||||
LOG(logDEBUG1, ("bytesWritten:%lu filesize:%lu\n", bytesWritten, filesize));
|
||||
}
|
||||
if (fclose(fp) != 0) {
|
||||
sprintf(mess, "Could not copy detector server. (closing file pointer)\n");
|
||||
LOG(logERROR, (mess));
|
||||
|
@ -9381,7 +9381,7 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
||||
totalsize);
|
||||
break;
|
||||
case PROGRAM_SERVER:
|
||||
ret = writeBinaryFile(mess, serverName, src, filesize);
|
||||
ret = writeBinaryFile(mess, serverName, src, totalsize);
|
||||
if (ret == OK) {
|
||||
ret = setupDetectorServer(mess, serverName);
|
||||
}
|
||||
|
@ -6,10 +6,10 @@
|
||||
#define APILIB 0x211027
|
||||
#define APIRECEIVER 0x211020
|
||||
#define APIGUI 0x211021
|
||||
#define APIEIGER 0x211110
|
||||
#define APICTB 0x211110
|
||||
#define APIGOTTHARD 0x211110
|
||||
#define APIGOTTHARD2 0x211110
|
||||
#define APIJUNGFRAU 0x211110
|
||||
#define APIMYTHEN3 0x211110
|
||||
#define APIMOENCH 0x211110
|
||||
#define APIEIGER 0x211110
|
||||
|
Reference in New Issue
Block a user