diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2016-07-26 12:45:10 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2016-07-26 12:45:10 +0200 |
commit | 88554d068d287870740b842864a50604f53e8509 (patch) | |
tree | a5ab19d45570ad111b7b9ee60613d9f01247b584 /src/plugins/canbus/peakcan/peakcanbackend.cpp | |
parent | eba0e3f243da949789871c3884c0ba158a3f6948 (diff) | |
parent | 36b24743ccecd56b132cd81f05842943ff716943 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
src/plugins/canbus/peakcan/peakcanbackend.cpp
One side renamed a member.
The other changed some code using it.
Change-Id: I14131122835ab9014894eadf4b529bdfd413e436
Diffstat (limited to 'src/plugins/canbus/peakcan/peakcanbackend.cpp')
-rw-r--r-- | src/plugins/canbus/peakcan/peakcanbackend.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/plugins/canbus/peakcan/peakcanbackend.cpp b/src/plugins/canbus/peakcan/peakcanbackend.cpp index ca666cf..920b2c0 100644 --- a/src/plugins/canbus/peakcan/peakcanbackend.cpp +++ b/src/plugins/canbus/peakcan/peakcanbackend.cpp @@ -208,13 +208,15 @@ bool PeakCanBackendPrivate::open() const int bitrate = q->configurationParameter(QCanBusDevice::BitRateKey).toInt(); const int bitrateCode = bitrateCodeFromBitrate(bitrate); - if (TPCANStatus st = ::CAN_Initialize(channelIndex, bitrateCode, 0, 0, 0) != PCAN_ERROR_OK) { + const TPCANStatus st = ::CAN_Initialize(channelIndex, bitrateCode, 0, 0, 0); + if (st != PCAN_ERROR_OK) { q->setError(systemErrorString(st), QCanBusDevice::ConnectionError); return false; } if (!acquireReadNotification()) { - if (TPCANStatus st = ::CAN_Uninitialize(channelIndex) != PCAN_ERROR_OK) + const TPCANStatus st = ::CAN_Uninitialize(channelIndex); + if (st != PCAN_ERROR_OK) q->setError(systemErrorString(st), QCanBusDevice::ConnectionError); return false; } @@ -235,8 +237,9 @@ void PeakCanBackendPrivate::close() writeNotifier = nullptr; } - if (TPCANStatus st = ::CAN_Uninitialize(channelIndex) != PCAN_ERROR_OK) - emit q->setError(systemErrorString(st), QCanBusDevice::ConnectionError); + const TPCANStatus st = ::CAN_Uninitialize(channelIndex); + if (st != PCAN_ERROR_OK) + q->setError(systemErrorString(st), QCanBusDevice::ConnectionError); isOpen = false; } @@ -249,7 +252,8 @@ bool PeakCanBackendPrivate::setConfigurationParameter(int key, const QVariant &v case QCanBusDevice::BitRateKey: return verifyBitRate(value.toInt()); default: - q->setError(PeakCanBackend::tr("Unsupported configuration key"), QCanBusDevice::ConfigurationError); + q->setError(PeakCanBackend::tr("Unsupported configuration key: %1").arg(key), + QCanBusDevice::ConfigurationError); return false; } } @@ -355,7 +359,8 @@ void PeakCanBackendPrivate::startWrite() else ::memcpy(message.DATA, payload.constData(), sizeof(message.DATA)); - if (TPCANStatus st = ::CAN_Write(channelIndex, &message) != PCAN_ERROR_OK) + const TPCANStatus st = ::CAN_Write(channelIndex, &message); + if (st != PCAN_ERROR_OK) q->setError(systemErrorString(st), QCanBusDevice::WriteError); else emit q->framesWritten(qint64(1)); @@ -378,8 +383,9 @@ bool PeakCanBackendPrivate::acquireReadNotification() } #endif - if (TPCANStatus st = ::CAN_SetValue(channelIndex, PCAN_RECEIVE_EVENT, &readHandle, sizeof(readHandle)) - != PCAN_ERROR_OK) { + const TPCANStatus st = ::CAN_SetValue(channelIndex, PCAN_RECEIVE_EVENT, + &readHandle, sizeof(readHandle)); + if (st != PCAN_ERROR_OK) { q->setError(systemErrorString(st), QCanBusDevice::ReadError); return false; } @@ -397,7 +403,8 @@ void PeakCanBackendPrivate::releaseReadNotification() Q_Q(PeakCanBackend); quint32 value = 0; - if (TPCANStatus st = ::CAN_SetValue(channelIndex, PCAN_RECEIVE_EVENT, &value, sizeof(value)) != PCAN_ERROR_OK) + const TPCANStatus st = ::CAN_SetValue(channelIndex, PCAN_RECEIVE_EVENT, &value, sizeof(value)); + if (st != PCAN_ERROR_OK) q->setError(systemErrorString(st), QCanBusDevice::ConnectionError); if (readNotifier) { @@ -428,7 +435,8 @@ void PeakCanBackendPrivate::startRead() TPCANTimestamp timestamp; ::memset(×tamp, 0, sizeof(timestamp)); - if (TPCANStatus st = ::CAN_Read(channelIndex, &message, ×tamp) != PCAN_ERROR_OK) { + const TPCANStatus st = ::CAN_Read(channelIndex, &message, ×tamp); + if (st != PCAN_ERROR_OK) { if (st != PCAN_ERROR_XMTFULL) q->setError(systemErrorString(st), QCanBusDevice::ReadError); break; @@ -489,10 +497,8 @@ bool PeakCanBackend::open() Q_D(PeakCanBackend); if (!d->isOpen) { - if (!d->open()) { - close(); // sets UnconnectedState + if (!d->open()) return false; - } // apply all stored configurations except bitrate, because // the bitrate can not be applied after opening of device |