Read dc-firmware-version: filter return value (null-character)

This commit is contained in:
Siegfried Siegert 2024-01-31 12:22:18 +01:00
parent 14755cd5b4
commit 0cc89cefab
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
3 changed files with 9 additions and 2 deletions

View File

@ -103,7 +103,7 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
hw->vend_failed();
// read sw-version and store it in persistentData, if changed
QString dc_fw_version = hw->dc_getSWversion();
QString dc_fw_version = hw->dc_getSWversion().remove(QChar('\0'));
qCritical() << "ATBDeviceControllerPlugin: DC firmware version: " << dc_fw_version;
this->persistentData->setDCFirmwareVersion(dc_fw_version);
this->persistentData->serializeToFile();

View File

@ -45,7 +45,11 @@ void DeviceControllerDiag::diagRequest()
this->private_startDiag();
// read dc-fw-version:
QString dc_fw_version = hw->dc_getSWversion();
/* note: dc_getSWVersion() returns always 32 characters (QString)...
* if no version string could be read it will contain 32 null-characters:
* "\u0000\u0000..."
*/
QString dc_fw_version = hw->dc_getSWversion().remove(QChar('\0'));
qCritical() << "ATBDeviceControllerPlugin: DC firmware version: " << dc_fw_version;
this->pData->setDCFirmwareVersion(dc_fw_version);
this->pData->serializeToFile();

View File

@ -125,6 +125,9 @@ QList<QString> PersistentData::uniqueKeys() const {
void PersistentData::setDCFirmwareVersion(const QString & fw_version)
{
// there must be a version string!
if (fw_version.size() < 1) return;
if (this->hash["dc_fw_version"].toString() != fw_version) {
this->isChangedFlag = true;
this->hash.insert("dc_fw_version", fw_version);