Compare commits
3 Commits
47f09067ea
...
4cc964e8c2
Author | SHA1 | Date | |
---|---|---|---|
4cc964e8c2 | |||
f910b7d057 | |||
5dd90e9597 |
@ -303,7 +303,18 @@ struct SharedMem
|
|||||||
|
|
||||||
// download of device controller and json files
|
// download of device controller and json files
|
||||||
struct DCDownload {
|
struct DCDownload {
|
||||||
char m_filename[512];
|
enum class FILE_INDEX {
|
||||||
|
DC_BINARY = 0, DC2C_CASH = 1, DC2C_CONF = 2, DC2C_SERIAL=3,
|
||||||
|
DC2C_PRINT_01, DC2C_PRINT_02, DC2C_PRINT_03, DC2C_PRINT_04,
|
||||||
|
DC2C_PRINT_05, DC2C_PRINT_06, DC2C_PRINT_07, DC2C_PRINT_08,
|
||||||
|
DC2C_PRINT_09, DC2C_PRINT_10, DC2C_PRINT_11, DC2C_PRINT_12,
|
||||||
|
DC2C_PRINT_13, DC2C_PRINT_14, DC2C_PRINT_15, DC2C_PRINT_16,
|
||||||
|
DC2C_PRINT_17, DC2C_PRINT_18, DC2C_PRINT_19, DC2C_PRINT_20,
|
||||||
|
DC2C_PRINT_21, DC2C_PRINT_22, DC2C_PRINT_23, DC2C_PRINT_24,
|
||||||
|
DC2C_PRINT_25, DC2C_PRINT_26, DC2C_PRINT_27, DC2C_PRINT_28,
|
||||||
|
DC2C_PRINT_29, DC2C_PRINT_30, DC2C_PRINT_31, DC2C_PRINT_32
|
||||||
|
};
|
||||||
|
char m_filename[(int)FILE_INDEX::DC2C_PRINT_32][512];
|
||||||
std::atomic_ushort m_totalBlocks;
|
std::atomic_ushort m_totalBlocks;
|
||||||
std::atomic_ushort m_currentblockNumber;
|
std::atomic_ushort m_currentblockNumber;
|
||||||
std::atomic_bool m_requested{false};
|
std::atomic_bool m_requested{false};
|
||||||
|
@ -100,31 +100,40 @@ DownloadThread::~DownloadThread() {
|
|||||||
*/
|
*/
|
||||||
void DownloadThread::run() {
|
void DownloadThread::run() {
|
||||||
// download thread running in ca-master sends the dc-file down to firmware
|
// download thread running in ca-master sends the dc-file down to firmware
|
||||||
#if 0
|
// TODO: send the json files as well
|
||||||
Update::DownloadResult Update::dc_downloadBinary(QByteArray const &b) const {
|
|
||||||
int const nBlocks = (((b.size())%64)==0) ? (b.size()/64) : (b.size()/64)+1;
|
|
||||||
|
|
||||||
// fill lst block of data to be sent with 0xFF
|
m_hw->dcDownloadRequestAck();
|
||||||
QByteArray ba = b.leftJustified(nBlocks*64, (char)(0xFF));
|
|
||||||
|
|
||||||
qInfo() << "total number of bytes to send to dc" << ba.size();
|
qCritical() << "DownloadThread::run(): DOWNLOAD THREAD STARTED";
|
||||||
qInfo() << "total number of blocks to send to dc" << nBlocks;
|
|
||||||
|
|
||||||
int bNum = 0;
|
// load binary device controller file into memory
|
||||||
|
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
||||||
|
if (ba.size() > 0) {
|
||||||
|
uint16_t const totalBlocks = (((ba.size())%64)==0) ? (ba.size()/64) : (ba.size()/64)+1;
|
||||||
|
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
||||||
|
|
||||||
|
// fill last block of data to be sent with 0xFF
|
||||||
|
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
||||||
|
|
||||||
|
resetDeviceController();
|
||||||
|
if (startBootloader()) {
|
||||||
|
|
||||||
|
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
||||||
|
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
||||||
|
|
||||||
|
int currentBlock = 0;
|
||||||
DownloadResult res = DownloadResult::OK;
|
DownloadResult res = DownloadResult::OK;
|
||||||
fprintf(stderr, "\n64-byte block %04d ", bNum);
|
qCritical() << "64-byte block " << currentBlock;
|
||||||
while (res != DownloadResult::ERROR && bNum < nBlocks) {
|
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
||||||
if ((res = sendNextAddress(bNum)) != DownloadResult::ERROR) {
|
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
|
||||||
if ((res = sendNextDataBlock(ba, bNum)) != DownloadResult::ERROR) {
|
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
|
||||||
bNum += 1;
|
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||||
fprintf(stderr, ".");
|
currentBlock += 1;
|
||||||
if ((bNum % 80) == 0) {
|
|
||||||
fprintf(stderr, "\n64-byte block %04d ", bNum);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fprintf(stderr, "\nlast 64-byte block %04d\n", bNum);
|
qCritical() << "DownloadThread::run(): last 64-byte block %04d" << currentBlock;
|
||||||
|
|
||||||
int const rest = ba.size() % 64;
|
int const rest = ba.size() % 64;
|
||||||
int const offset = ba.size() - rest;
|
int const offset = ba.size() - rest;
|
||||||
@ -135,21 +144,18 @@ void DownloadThread::run() {
|
|||||||
uint8_t local[66];
|
uint8_t local[66];
|
||||||
memset(local, 0xFF, sizeof(local));
|
memset(local, 0xFF, sizeof(local));
|
||||||
memcpy(local, startAddress, rest);
|
memcpy(local, startAddress, rest);
|
||||||
qCritical() << "ERROR SEND REMAINING" << rest << "BYTES";
|
qCritical() << "DownloadThread::run(): ERROR SEND REMAINING" << rest << "BYTES";
|
||||||
m_hw->bl_sendDataBlock(64, local);
|
m_hw->bl_sendDataBlock(64, local);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
m_hw->bl_sendLastBlock();
|
m_hw->bl_sendLastBlock();
|
||||||
qInfo() << "last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
||||||
|
}
|
||||||
|
stopBootloader(); // there is no harm in stopping the bootloader even
|
||||||
|
} // if it was not started at all
|
||||||
|
|
||||||
#endif
|
#if 0
|
||||||
|
|
||||||
m_hw->dcDownloadRequestAck();
|
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + "DOWNLOAD THREAD STARTED";
|
|
||||||
|
|
||||||
// test code:
|
// test code:
|
||||||
uint16_t const totalBlocks = 100;
|
uint16_t const totalBlocks = 100;
|
||||||
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
||||||
@ -158,6 +164,7 @@ void DownloadThread::run() {
|
|||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||||
QThread::msleep(100);
|
QThread::msleep(100);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
m_hw->dcDownloadSetRunning(false);
|
m_hw->dcDownloadSetRunning(false);
|
||||||
m_hw->dcDownloadSetFinished(true);
|
m_hw->dcDownloadSetFinished(true);
|
||||||
|
@ -4387,7 +4387,7 @@ bool hwapi::dcDownloadRequest(QString const &dcFileToDownload) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *fNameBuffer = data->m_downLoadDC.m_filename;
|
char *fNameBuffer = data->m_downLoadDC.m_filename[(int)SharedMem::DCDownload::FILE_INDEX::DC_BINARY];
|
||||||
size_t const size = sizeof(data->m_downLoadDC.m_filename);
|
size_t const size = sizeof(data->m_downLoadDC.m_filename);
|
||||||
|
|
||||||
std::memset(fNameBuffer, 0x00, size);
|
std::memset(fNameBuffer, 0x00, size);
|
||||||
@ -4575,7 +4575,7 @@ bool hwapi::dcDownloadReportFinished() {
|
|||||||
|
|
||||||
QString hwapi::dcDownloadFileName() const {
|
QString hwapi::dcDownloadFileName() const {
|
||||||
SharedMem const *data = SharedMem::getDataConst();
|
SharedMem const *data = SharedMem::getDataConst();
|
||||||
return data ? data->m_downLoadDC.m_filename : "";
|
return data ? data->m_downLoadDC.m_filename[(int)SharedMem::DCDownload::FILE_INDEX::DC_BINARY] : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hwapi::dcDownloadSetRequested(bool requested) {
|
bool hwapi::dcDownloadSetRequested(bool requested) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user