do {
if ((status = trb_register_write(trb_address, SetupReg,
(uint32_t) (value << 24))) == -1) {
- fprintf(logFile, "Error > writeSetupRegister: TRBNet %s\n",
- trb_strerror());
+ fprintf(logFile,
+ "Error line %d > writeSetupRegister: TRBNet %s\n",
+ __LINE__, trb_strerror());
return -1;
}
/* Check timeout */
if (ctr >= timeout) {
- fprintf(logFile, "Error > writeSetupRegister: timeout\n");
+ fprintf(logFile,
+ "Error line %d > __LINE__ writeSetupRegister: timeout\n",
+ __LINE__);
return -1;
}
ctr++;
if (trb_term.status_channel != 0) {
fprintf(logFile,
- "Error > writeSetupRegister: invalid Status returned %s\n",
- trb_strerror());
+ "Error line %d > writeSetupRegister: invalid Status returned %s\n",
+ __LINE__, trb_strerror());
return -1;
}
do {
if ((status = trb_register_read(trb_address, CtrlReg,
trbBuffer, TRB_BUFFER_SIZE)) == -1) {
- fprintf(logFile, "Error > readCtrlRegister: TRBNet %s\n",
- trb_strerror());
+ fprintf(logFile, "Error line %d > readCtrlRegister: TRBNet %s\n",
+ __LINE__, trb_strerror());
return -1;
}
/* Check timeout */
if (ctr >= timeout) {
- fprintf(logFile, "Error > readCtrlRegister: timeout\n");
+ fprintf(logFile, "Error line %d > readCtrlRegister: timeout\n", __LINE__);
return -1;
}
ctr++;
} while (trb_term.status_channel != 0);
if (status <= 0) {
- fprintf(logFile, "Error > readCtrlRegister: %s\n", trb_strerror());
+ fprintf(logFile, "Error line %d > readCtrlRegister: %s\n",
+ __LINE__, trb_strerror());
return -1;
}
/* Wait until NoMoreData is withdrawn */
do {
if ((status = trb_register_write(trb_address, CtrlReg, value)) == -1) {
- fprintf(logFile, "Error > writeCtrlRegister: TRBNet %s\n",
- trb_strerror());
+ fprintf(logFile, "Error line %d > writeCtrlRegister: TRBNet %s\n",
+ __LINE__, trb_strerror());
return -1;
}
/* Check timeout */
if (ctr >= timeout) {
- fprintf(logFile, "Error writeCtrlRegister, timeout\n");
+ fprintf(logFile,
+ "Error line %d > Error writeCtrlRegister, timeout\n", __LINE__);
return -1;
}
ctr++;
if ((status =
trb_register_read(trb_address, BlockRam, trbBuffer,
TRB_BUFFER_SIZE)) == -1) {
- fprintf(logFile, "Error > checkStatus: TRBNet %s\n", trb_strerror());
+ fprintf(logFile,
+ "Error line %d > checkStatus: TRBNet %s\n",
+ __LINE__, trb_strerror());
return -1;
}
(flashParamRef.manId == 0x00471f)) {
/* Check EPE Bit (ADCM and SHOWER) */
if (((trbBuffer[i + 1] >> 5) & 0x01) == 1) {
- fprintf(logFile, "Error > checkStatus: Erase or program error on "
- "EndPoint 0x%04x\n", trbBuffer[i] & 0xffff);
+ fprintf(logFile,
+ "Error line %d > checkStatus: Erase or program error on "
+ "EndPoint 0x%04x\n",
+ __LINE__, trbBuffer[i] & 0xffff);
return -1; /* Fatal Error */
}
}
/* Enable writing */
if (sendCommand(trb_address, 0x06 << 24, 0) == -1) {
- fprintf(logFile, "Error > writeStatusRegister: write enable\n");
+ fprintf(logFile,
+ "Error line %d > writeStatusRegister: write enable\n", __LINE__);
return -1;
}
if (trb_register_write(trb_address, BlockRam, (uint32_t) value) == -1) {
- fprintf(logFile, "Error > writeStatusRegister: TRBNet %s\n",
- trb_strerror());
+ fprintf(logFile,
+ "Error line %d > writeStatusRegister: TRBNet %s\n",
+ __LINE__, trb_strerror());
return -1;
}
if (sendCommand(trb_address, 0x01 << 24, 0) == -1) {
- fprintf(logFile, "Error > writeStatusRegister: sendCommand\n");
+ fprintf(logFile,
+ "Error line %d > writeStatusRegister: sendCommand\n", __LINE__);
return -1;
}
}
if (status != 0) {
- fprintf(logFile, "Error > writeStatusRegister: invalid status\n");
+ fprintf(logFile,
+ "Error line %d > writeStatusRegister: invalid status\n", __LINE__);
return -1;
}
if ((status =
trb_register_read(trb_address, HardwareId, trbBuffer,
TRB_BUFFER_SIZE)) == -1) {
- fprintf(logFile, "Error > initTransfer, read HardwareIds: TRBNet %s\n",
- trb_strerror());
+ fprintf(logFile,
+ "Error line %d > initTransfer, read HardwareIds: TRBNet %s\n",
+ __LINE__, trb_strerror());
return -1;
}
if ((status =
trb_register_read(trb_address, BlockRam, trbBuffer,
TRB_BUFFER_SIZE)) == -1) {
- fprintf(logFile, "Error > initTransfer, read ManIds: TRBNet %s\n",
- trb_strerror());
+ fprintf(logFile, "Error line %d > initTransfer, read ManIds: TRBNet %s\n",
+ __LINE__, trb_strerror());
return -1;
}
if ((status = trb_register_read_mem(trb_address, BlockRam, 0, size,
trbBuffer, TRB_BUFFER_SIZE))
== -1) {
- fprintf(logFile, "Error > readPage: TRBNet %s\n", trb_strerror());
+ fprintf(logFile, "Error line %d > readPage: TRBNet %s\n",
+ __LINE__, trb_strerror());
return -1;
}
if (len != size) {
fprintf(logFile,
- "Error > readPage: Invalid len %d returned by endpoint 0x%04x\n",
- len, address);
+ "Error line %d > readPage: Invalid len %d returned by "
+ "endpoint 0x%04x\n", __LINE__, len, address);
}
/* read one page */
if ((status = trb_register_write_mem(trb_address, BlockRam, 0,
trbBuffer, size))
== -1) {
- fprintf(logFile, "Error > writePage: TRBNet %s\n", trb_strerror());
+ fprintf(logFile, "Error line %d > writePage: TRBNet %s\n",
+ __LINE__, trb_strerror());
return -1;
}
/* Enable writing */
if (sendCommand(trb_address, 0x06 << 24, 0) == -1) {
- fprintf(logFile, "Error > writePage: write enable\n");
+ fprintf(logFile, "Error line %d > writePage: write enable\n", __LINE__);
return -1;
}
/* Write page */
trbcmd = (0x02 << 24) | ((pageNumber * PAGE_SIZE) & 0xffffff);
if (sendCommand(trb_address, trbcmd, numBytes - 1) == -1) {
- fprintf(logFile, "Error > writePage: write page\n");
+ fprintf(logFile, "Error line %d > writePage: write page\n", __LINE__);
return -1;
}
}
if (status != 0) {
- fprintf(logFile, "Error > pageWrite: invalid status\n");
+ fprintf(logFile, "Error line %d > pageWrite: invalid status\n", __LINE__);
return -1;
}
error = -1;
errorCtr++;
fprintf(logFile,
- "verify failed page #%d, byte #%d "
+ "Error > verify failed page #%d, byte #%d "
"(exp: 0x%02x rec: 0x%02x), EndPoint: 0x%04x\n",
page, c,
imageBuffer[page * PAGE_SIZE + c],
error = -1;
errorCtr++;
fprintf(logFile,
- "verify failed InfoPage, byte #%d "
+ "Error > verify failed InfoPage, byte #%d "
"(exp: 0x%02x rec: 0x%02x), EndPoint: 0x%04x\n",
c,
imageBuffer[(NUM_PAGES - 1) * PAGE_SIZE + c],
if (imageSize > (PAGE_SIZE * NUM_PAGES)) {
fprintf(logFile,
- "Error > readImageFile: Imagefile '%s' is too large (%d bytes)\n",
+ "Error > readImageFile: Imagefile '%s' is too large"
+ " (%d bytes)\n",
imageFileName, imageSize);
return -1;
}
}
if (stat(fileName, &statBuf) == -1) {
- fprintf(logFile, "Error > prepareInfoPage: statCall failed: %s\n",
- strerror(errno));
+ fprintf(logFile,
+ "Error line %d > prepareInfoPage: statCall failed: %s\n",
+ __LINE__, strerror(errno));
return -1;
}
snprintf(buffer + 0, 63, "NAME: %s", basename((char *)fileName));
/* Open LogFile */
logFile = fopen(logFileName, "w+");
if (logFile == NULL) {
- fprintf(stderr, "Could not open logFile %s: %s\n",
+ fprintf(stderr,
+ "Error > Could not open logFile %s: %s\n",
logFileName, strerror(errno));
return -1;
}
/* Select MDC-FlashRom */
if (trb_register_write(trb_address, MDCFlashRomSelect,
(uint32_t) number) == -1) {
- fprintf(logFile, "\nError > selcetMdcFlashRom: TRBNet %s\n",
- trb_strerror());
+ fprintf(logFile, "\nError line %d > selectMdcFlashRom: TRBNet %s\n",
+ __LINE__, trb_strerror());
return -1;
}