Added helper functions. Update will be used heavily by the Worker-class in a later stage.
This commit is contained in:
parent
9ed51d60e4
commit
f963b61ebc
44
update.cpp
44
update.cpp
@ -81,9 +81,14 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
|
|||||||
|
|
||||||
Update::Update(hwinf *hw,
|
Update::Update(hwinf *hw,
|
||||||
QString update_ctrl_file,
|
QString update_ctrl_file,
|
||||||
|
QString repositoryPath,
|
||||||
|
QString customerId,
|
||||||
|
QString branchName,
|
||||||
QString workingDir,
|
QString workingDir,
|
||||||
bool maintenanceMode,
|
bool maintenanceMode,
|
||||||
bool testMode,
|
bool testMode,
|
||||||
|
bool executeScriptOnly,
|
||||||
|
bool dryRun,
|
||||||
QObject *parent,
|
QObject *parent,
|
||||||
char const *serialInterface,
|
char const *serialInterface,
|
||||||
char const *baudrate)
|
char const *baudrate)
|
||||||
@ -93,11 +98,19 @@ Update::Update(hwinf *hw,
|
|||||||
, m_baudrate(baudrate)
|
, m_baudrate(baudrate)
|
||||||
, m_update_ctrl_file(update_ctrl_file)
|
, m_update_ctrl_file(update_ctrl_file)
|
||||||
, m_update_ctrl_file_copy(update_ctrl_file + ".copy")
|
, m_update_ctrl_file_copy(update_ctrl_file + ".copy")
|
||||||
|
, m_repositoryPath(repositoryPath)
|
||||||
|
, m_customerId(customerId)
|
||||||
|
, m_branchName(branchName)
|
||||||
, m_workingDir(workingDir)
|
, m_workingDir(workingDir)
|
||||||
, m_maintenanceMode(maintenanceMode)
|
, m_maintenanceMode(maintenanceMode)
|
||||||
, m_testMode(testMode)
|
, m_testMode(testMode)
|
||||||
|
, m_executeScriptOnly(executeScriptOnly)
|
||||||
|
, m_dryRun(dryRun)
|
||||||
|
//, m_apismClient(nullptr, nullptr, nullptr)
|
||||||
, m_init(true) {
|
, m_init(true) {
|
||||||
|
|
||||||
|
// m_apismClient.sendSelfTest();
|
||||||
|
|
||||||
if (!m_testMode) {
|
if (!m_testMode) {
|
||||||
// make sure the files are empty
|
// make sure the files are empty
|
||||||
if (m_update_ctrl_file.exists()) {
|
if (m_update_ctrl_file.exists()) {
|
||||||
@ -213,7 +226,7 @@ Update::DownloadResult Update::sendNextAddress(int bNum) const {
|
|||||||
int noAnswerCount = 0;
|
int noAnswerCount = 0;
|
||||||
int errorCount = 0;
|
int errorCount = 0;
|
||||||
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
||||||
qDebug() << "addr-block" << bNum << "...";
|
// qDebug() << "addr-block" << bNum << "...";
|
||||||
while (noAnswerCount <= 250) {
|
while (noAnswerCount <= 250) {
|
||||||
m_hw->bl_sendAddress(bNum);
|
m_hw->bl_sendAddress(bNum);
|
||||||
QThread::msleep(100);
|
QThread::msleep(100);
|
||||||
@ -225,7 +238,7 @@ Update::DownloadResult Update::sendNextAddress(int bNum) const {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
} else { // res == DownloadResult::OK
|
} else { // res == DownloadResult::OK
|
||||||
qInfo() << "addr-block" << bNum << "...OK";
|
// qInfo() << "addr-block" << bNum << "...OK";
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -285,13 +298,20 @@ Update::DownloadResult Update::dc_downloadBinary(QByteArray const &b) const {
|
|||||||
|
|
||||||
int bNum = 0;
|
int bNum = 0;
|
||||||
DownloadResult res = DownloadResult::OK;
|
DownloadResult res = DownloadResult::OK;
|
||||||
|
fprintf(stderr, "\n64-byte block %04d ", bNum);
|
||||||
while (res != DownloadResult::ERROR && bNum < nBlocks) {
|
while (res != DownloadResult::ERROR && bNum < nBlocks) {
|
||||||
if ((res = sendNextAddress(bNum)) != DownloadResult::ERROR) {
|
if ((res = sendNextAddress(bNum)) != DownloadResult::ERROR) {
|
||||||
if ((res = sendNextDataBlock(ba, bNum)) != DownloadResult::ERROR) {
|
if ((res = sendNextDataBlock(ba, bNum)) != DownloadResult::ERROR) {
|
||||||
bNum += 1;
|
bNum += 1;
|
||||||
|
fprintf(stderr, ".");
|
||||||
|
if ((bNum % 80) == 0) {
|
||||||
|
fprintf(stderr, "\n64-byte block %04d ", bNum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fprintf(stderr, "\nlast 64-byte block %04d\n", bNum);
|
||||||
|
|
||||||
int const rest = ba.size() % 64;
|
int const rest = ba.size() % 64;
|
||||||
int const offset = ba.size() - rest;
|
int const offset = ba.size() - rest;
|
||||||
char const *startAddress = ba.constData() + offset;
|
char const *startAddress = ba.constData() + offset;
|
||||||
@ -619,8 +639,15 @@ void Update::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
|||||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardError()));
|
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bool Update::executeProcess(QString const &cmd);
|
||||||
|
|
||||||
bool Update::doUpdate() {
|
bool Update::doUpdate() {
|
||||||
|
|
||||||
|
//
|
||||||
|
// ACHTUNG !!!
|
||||||
|
//
|
||||||
|
return true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The file referred to by 'update_data' has the following structure for
|
The file referred to by 'update_data' has the following structure for
|
||||||
each line:
|
each line:
|
||||||
@ -643,6 +670,10 @@ bool Update::doUpdate() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_executeScriptOnly) { // basically a test flag for executing only the
|
||||||
|
return true; // update script.
|
||||||
|
}
|
||||||
|
|
||||||
bool serialOpened = false;
|
bool serialOpened = false;
|
||||||
bool serialOpen = false;
|
bool serialOpen = false;
|
||||||
|
|
||||||
@ -709,10 +740,11 @@ bool Update::doUpdate() {
|
|||||||
if (!linkTarget.exists()) { // check for broken link
|
if (!linkTarget.exists()) { // check for broken link
|
||||||
res = false;
|
res = false;
|
||||||
} else {
|
} else {
|
||||||
if (fwVersion.startsWith(linkTarget.completeBaseName())) {
|
if (false) {
|
||||||
qCritical() << "current dc-firmware-version" << fwVersion
|
//if (fwVersion.startsWith(linkTarget.completeBaseName())) {
|
||||||
<< "already installed";
|
// qCritical() << "current dc-firmware-version" << fwVersion
|
||||||
res = false;
|
// << "already installed";
|
||||||
|
// res = false;
|
||||||
} else {
|
} else {
|
||||||
res = true;
|
res = true;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user