binaries in

This commit is contained in:
maliakal_d 2021-09-14 16:01:05 +02:00
parent d599d75e0b
commit fdd8b52ce1
10 changed files with 37 additions and 13 deletions

View File

@ -78,6 +78,7 @@ int deleteOldFile(char *mess) {
LOG(logERROR, (mess)); LOG(logERROR, (mess));
return FAIL; return FAIL;
} }
LOG(logINFO, ("\tDeleted old programming file (%s)\n", TEMP_PROG_FILE_NAME));
return OK; return OK;
} }
@ -139,11 +140,12 @@ int copyToFlash(ssize_t fsize, char *clientChecksum, char *mess) {
return FAIL; return FAIL;
} }
/* ignoring this until a consistent way to read from bfin flash
if (verifyChecksumFromFlash(mess, clientChecksum, flashDriveName, fsize) == if (verifyChecksumFromFlash(mess, clientChecksum, flashDriveName, fsize) ==
FAIL) { FAIL) {
return FAIL; return FAIL;
} }
*/
if (waitForFPGAtoTouchFlash(mess) == FAIL) { if (waitForFPGAtoTouchFlash(mess) == FAIL) {
return FAIL; return FAIL;
} }
@ -312,7 +314,7 @@ int waitForFPGAtoTouchFlash(char* mess) {
#ifdef VIRTUAL #ifdef VIRTUAL
return OK; return OK;
#endif #endif
LOG(logINFO, ("Waiting for FPGA to program from flash\n")); LOG(logINFO, ("\tWaiting for FPGA to program from flash\n"));
int timeSpent = 0; int timeSpent = 0;
int result = 0; int result = 0;
@ -339,9 +341,11 @@ int waitForFPGAtoTouchFlash(char* mess) {
} }
// convert to int // convert to int
if (sscanf(retvals, "%d", &result) != 1) { result = 1;
sprintf(mess, "Could not program fpga. (could not scan int for gpio status: %s)\n", int retval = sscanf(retvals, "%d\n", &result);
retvals); if (retval != 1) {
sprintf(mess, "Could not program fpga. (could not scan int for gpio status: [%s] retval:%d, result:%d)\n",
retvals, retval, result);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
return FAIL; return FAIL;
} }

View File

@ -445,11 +445,13 @@ int executeCommand(char *command, char *result, enum TLogLevel level) {
memset(temp, 0, tempsize); memset(temp, 0, tempsize);
memset(result, 0, MAX_STR_LENGTH); memset(result, 0, MAX_STR_LENGTH);
LOG(level, ("Executing command:\n[%s]\n", command)); // copy command
strcat(command, " 2>&1"); char cmd[MAX_STR_LENGTH]= {0};
sprintf(cmd, "%s 2>&1", command);
LOG(level, ("Executing command:\n[%s]\n", cmd));
fflush(stdout); fflush(stdout);
FILE *sysFile = popen(command, "r"); FILE *sysFile = popen(cmd, "r");
while (fgets(temp, tempsize, sysFile) != NULL) { while (fgets(temp, tempsize, sysFile) != NULL) {
// size left excludes terminating character // size left excludes terminating character
size_t sizeleft = MAX_STR_LENGTH - strlen(result) - 1; size_t sizeleft = MAX_STR_LENGTH - strlen(result) - 1;

View File

@ -3479,7 +3479,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
// simulating erasing flash // simulating erasing flash
{ {
LOG(logINFO) << "Erasing Flash for module " << moduleIndex << " (" LOG(logINFO) << "(Simulating) Erasing Flash for module " << moduleIndex << " ("
<< shm()->hostname << ")"; << shm()->hostname << ")";
printf("%d%%\r", 0); printf("%d%%\r", 0);
std::cout << std::flush; std::cout << std::flush;
@ -3499,9 +3499,27 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
printf("\n"); printf("\n");
} }
// copied to flash // simulating writing to flash
LOG(logINFO) << "Writing to Flash to module " << moduleIndex << " (" {
<< shm()->hostname << ")"; LOG(logINFO) << "(Simulating) Writing to Flash for module " << moduleIndex << " (" << shm()->hostname << ")";
printf("%d%%\r", 0);
std::cout << std::flush;
// writing takes 30 seconds, printing here (otherwise need threads
// in server-unnecessary)
const int ERASE_TIME = 30;
int count = ERASE_TIME + 1;
while (count > 0) {
std::this_thread::sleep_for(std::chrono::seconds(1));
--count;
printf(
"%d%%\r",
static_cast<int>(
(static_cast<double>(ERASE_TIME - count) / ERASE_TIME) * 100));
std::cout << std::flush;
}
printf("\n");
}
if (client.Receive<int>() == FAIL) { if (client.Receive<int>() == FAIL) {
std::ostringstream os; std::ostringstream os;
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")" os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"

View File

@ -10,4 +10,4 @@
#define APIGOTTHARD2 0x210914 #define APIGOTTHARD2 0x210914
#define APIJUNGFRAU 0x210914 #define APIJUNGFRAU 0x210914
#define APIMYTHEN3 0x210914 #define APIMYTHEN3 0x210914
#define APIMOENCH 0x210909 #define APIMOENCH 0x210914