Compare commits

..

No commits in common. "e5ab9b98cd0d55deb5ce7c2b4df8723f1864a896" and "e24022a612ce8044600ccdfda57e594c4e5c3a79" have entirely different histories.

2 changed files with 111 additions and 120 deletions

View File

@ -119,9 +119,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
# : Improve output of GUI/Console and messages sent to ISMAS.
# : Fix: do not send the json-files to dc in any case. Bug introduced
# when pulling new branch, but branch already existed locally.
# 1.4.6 : No exit()-call if loading CA-plugin fails.
# Check m_hw (pointer to CA-(Slave)Plugin) before its use.
VERSION="1.4.7"
VERSION="1.4.6"
# PLANNED TODOS:
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu

View File

@ -52,6 +52,7 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
qCritical() << "in directory" << plugInDir.absolutePath();
qCritical() << "cannot load plugin" << pluginLoader.fileName();
qCritical() << pluginLoader.errorString();
exit(-1);
}
qCritical() << "loadDCPlugin() plugin directory:" << plugInDir.absolutePath();
@ -59,20 +60,25 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
if (!pluginLoader.isLoaded()) {
qCritical() << pluginLoader.errorString();
exit(-2);
}
QObject *plugin = pluginLoader.instance();
if (!plugin) {
qCritical() << "cannot start instance";
exit(-3);
}
if (! (hw = qobject_cast<hwinf *>(plugin))) {
qCritical() << "cannot cast plugin" << plugin << "to hwinf";
exit(-4);
}
} else {
qCritical() << pluginLibName << "does not exist";
exit(-5);
}
} else {
qCritical() << "plugins directory" << plugInDir.absolutePath()
<< "does not exist";
exit(-6);
}
return hw;
}
@ -118,7 +124,7 @@ Update::Update(Worker *worker,
, m_sys_areDCdataValid(false) {
if (!m_hw) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_hw == nullptr -> ca-slave plugin not loaded";
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_hw == nullptr -> ca-slave plugin loaded ???";
} else {
int tries = 20;
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
@ -185,37 +191,33 @@ void Update::onReportDCDownloadFailure(QString const &errorMsg) {
// br is a index into a table, used for historical reasons.
bool Update::openSerial(int br, QString baudrate, QString comPort) const {
if (m_hw) {
qDebug() << "opening serial" << br << baudrate << comPort << "...";
if (m_hw->dc_openSerial(br, baudrate, comPort, 1) == true) { // 1 for connect
Utils::printInfoMsg(
QString("OPENING SERIAL %1").arg(br)
+ " " + baudrate + " " + comPort + "...OK");
// m_hw->dc_autoRequest(true);
m_hw->dc_autoRequest(false);
QThread::sleep(1);
Utils::printInfoMsg(QString("IS PORT OPEN %1").arg(m_hw->dc_isPortOpen()));
return true;
}
Utils::printCriticalErrorMsg(
qDebug() << "opening serial" << br << baudrate << comPort << "...";
if (m_hw->dc_openSerial(br, baudrate, comPort, 1) == true) { // 1 for connect
Utils::printInfoMsg(
QString("OPENING SERIAL %1").arg(br)
+ " " + baudrate + " " + comPort + "...FAILED");
+ " " + baudrate + " " + comPort + "...OK");
// m_hw->dc_autoRequest(true);
m_hw->dc_autoRequest(false);
QThread::sleep(1);
Utils::printInfoMsg(QString("IS PORT OPEN %1").arg(m_hw->dc_isPortOpen()));
return true;
}
Utils::printCriticalErrorMsg(
QString("OPENING SERIAL %1").arg(br)
+ " " + baudrate + " " + comPort + "...FAILED");
return false;
}
void Update::closeSerial() const {
qInfo() << "CLOSED SERIAL" << m_baudrate << m_serialInterface;
if (m_hw) {
m_hw->dc_closeSerial();
}
m_hw->dc_closeSerial();
}
bool Update::isSerialOpen() const {
return m_hw ? m_hw->dc_isPortOpen() : false;
return m_hw->dc_isPortOpen();
}
/*
@ -394,88 +396,78 @@ bool Update::downloadJson(enum FileTypeJson type,
int templateIdx,
QString jsFileToSendToDC) const {
bool ret = false;
if (m_hw) {
m_hw->dc_autoRequest(true); // downloading Json needs the AutoEmission flag
qDebug() << "SET AUTO-REQUEST=TRUE";
QThread::sleep(1); // make sure the auto-request flag is acknowledged
m_hw->dc_autoRequest(true); // downloading Json needs the AutoEmission flag
qDebug() << "SET AUTO-REQUEST=TRUE";
QThread::sleep(1); // make sure the auto-request flag is acknowledged
QStringList lst;
bool ready = false;
int nTry = 25;
while ((ready = m_hw->sys_ready4sending()) == false) {
QThread::msleep(200);
if (--nTry <= 0) {
QString msg("SYS NOT READY FOR SENDING AFTER 5 SECONDS");
Utils::printCriticalErrorMsg(msg);
lst << msg;
QStringList lst;
bool ready = false;
int nTry = 25;
while ((ready = m_hw->sys_ready4sending()) == false) {
QThread::msleep(200);
if (--nTry <= 0) {
QString msg("SYS NOT READY FOR SENDING AFTER 5 SECONDS");
Utils::printCriticalErrorMsg(msg);
lst << msg;
if (m_worker) {
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
}
break;
if (m_worker) {
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
}
break;
}
}
QString msg;
lst.clear();
if (ready) {
QFile file(jsFileToSendToDC);
QFileInfo fi(jsFileToSendToDC); // max. size of template file is 800 bytes
if (file.exists()) {
if (file.open(QIODevice::ReadOnly)) {
if (fi.size() > 0 && fi.size() <= 800) {
QByteArray ba = file.readAll();
// kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer
// nrOfTemplate=1...32 if kindOfFile==6
// content = content of the Json file, max 800byte ascii signs
if (m_hw->sys_sendJsonFileToDc((uint8_t)(type),
templateIdx,
(uint8_t *)ba.data())) {
bool ret = false;
QString msg;
lst.clear();
if (ready) {
QFile file(jsFileToSendToDC);
QFileInfo fi(jsFileToSendToDC); // max. size of template file is 800 bytes
if (file.exists()) {
if (file.open(QIODevice::ReadOnly)) {
if (fi.size() > 0 && fi.size() <= 800) {
QByteArray ba = file.readAll();
// kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer
// nrOfTemplate=1...32 if kindOfFile==6
// content = content of the Json file, max 800byte ascii signs
if (m_hw->sys_sendJsonFileToDc((uint8_t)(type),
templateIdx,
(uint8_t *)ba.data())) {
/*
* Note: the machine id is contained in DC2C_conf.json.
* The idea was to use this to check if the download of
* the json-file was correct. It did not work, as the
* update of the PSA (to reflect a change in the
* machine id) did not happen immediately.
*
m_hw->dc_autoRequest(true);
QThread::msleep(500);
/*
* Note: the machine id is contained in DC2C_conf.json.
* The idea was to use this to check if the download of
* the json-file was correct. It did not work, as the
* update of the PSA (to reflect a change in the
* machine id) did not happen immediately.
*
m_hw->dc_autoRequest(true);
QThread::msleep(500);
// testing
m_hw->request_ReadbackMachineID();
QThread::msleep(500);
// testing
m_hw->request_ReadbackMachineID();
QThread::msleep(500);
uint8_t data[64];
memset(data, 0x00, sizeof(data));
uint8_t length = 0;
uint8_t data[64];
memset(data, 0x00, sizeof(data));
uint8_t length = 0;
m_hw->readback_machineIDdata(&length, data);
m_hw->readback_machineIDdata(&length, data);
QThread::msleep(500);
QThread::msleep(500);
QByteArray ba((const char*)data, length);
QByteArray ba((const char*)data, length);
qCritical() << length << "MACHINE ID =" << ba.toHex(':');
*/
qCritical() << length << "MACHINE ID =" << ba.toHex(':');
*/
if (m_worker) {
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
}
ret = true;
} else {
msg = QString("ERROR SEND JSON-FILE %1 TO DC").arg(file.fileName());
Utils::printCriticalErrorMsg(msg);
lst << msg;
if (m_worker) {
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
}
if (m_worker) {
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
}
ret = true;
} else {
msg = QString("SIZE OF %1 TOO BIG (%2 BYTES)").arg(jsFileToSendToDC).arg(fi.size());
msg = QString("ERROR SEND JSON-FILE %1 TO DC").arg(file.fileName());
Utils::printCriticalErrorMsg(msg);
lst << msg;
if (m_worker) {
@ -484,17 +476,16 @@ bool Update::downloadJson(enum FileTypeJson type,
}
}
} else {
msg = QString("CAN NOT OPEN ") + jsFileToSendToDC + " FOR READING";
msg = QString("SIZE OF %1 TOO BIG (%2 BYTES)").arg(jsFileToSendToDC).arg(fi.size());
Utils::printCriticalErrorMsg(msg);
lst << msg;
if (m_worker) {
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
}
}
} else {
msg = QString(jsFileToSendToDC) + " DOES NOT EXIST";
msg = QString("CAN NOT OPEN ") + jsFileToSendToDC + " FOR READING";
Utils::printCriticalErrorMsg(msg);
lst << msg;
@ -503,13 +494,22 @@ bool Update::downloadJson(enum FileTypeJson type,
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
}
}
}
} else {
msg = QString(jsFileToSendToDC) + " DOES NOT EXIST";
Utils::printCriticalErrorMsg(msg);
lst << msg;
m_hw->dc_autoRequest(false);
qDebug() << "SET AUTO-REQUEST=FALSE";
QThread::sleep(1); // make sure the auto-request flag is acknowledged
if (m_worker) {
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
}
}
}
m_hw->dc_autoRequest(false);
qDebug() << "SET AUTO-REQUEST=FALSE";
QThread::sleep(1); // make sure the auto-request flag is acknowledged
return ret;
}
@ -564,26 +564,24 @@ void Update::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
}
QStringList Update::getDcSoftAndHardWareVersion() {
if (m_hw) {
m_hw->dc_autoRequest(true);
QThread::sleep(1); // make sure the timer-slots are active
m_hw->dc_autoRequest(true);
QThread::sleep(1); // make sure the timer-slots are active
for (int i=0; i < 3; ++i) { // send explicit reuests to get
// current SW/HW-versions
m_hw->request_DC2_SWversion();
m_hw->request_DC2_HWversion();
QThread::sleep(1);
}
for (int i=0; i < 3; ++i) { // send explicit reuests to get
// current SW/HW-versions
m_hw->request_DC2_SWversion();
m_hw->request_DC2_HWversion();
QThread::sleep(1);
}
QString const &hwVersion = m_hw->dc_getHWversion().toLower().trimmed();
QString const &swVersion = m_hw->dc_getSWversion().toLower().trimmed();
QString const &hwVersion = m_hw->dc_getHWversion().toLower().trimmed();
QString const &swVersion = m_hw->dc_getSWversion().toLower().trimmed();
m_hw->dc_autoRequest(false);
QThread::sleep(1); // make sure the timer-slots are inactive
m_hw->dc_autoRequest(false);
QThread::sleep(1); // make sure the timer-slots are inactive
if (!hwVersion.isEmpty() && !swVersion.isEmpty()) {
return QStringList() << hwVersion << swVersion;
}
if (!hwVersion.isEmpty() && !swVersion.isEmpty()) {
return QStringList() << hwVersion << swVersion;
}
return QStringList() << "DC HW-version not available"
@ -673,11 +671,6 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
}
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
if (!m_hw) {
Utils::printInfoMsg("CA-PLUGIN NOT LOADED");
return false;
}
int tries = 20;
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
// must deliver 'true', only then are all data from hwapi valid