summaryrefslogtreecommitdiffstats
path: root/src/plugins/canbus/peakcan/peakcanbackend.cpp
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2015-09-03 13:14:24 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2015-09-06 06:52:13 +0000
commit8cb95caf1dbbd7426418e50fa70a7a27d208b573 (patch)
treec08a18c38f246eb2aba7826b636fbe3a31a12d60 /src/plugins/canbus/peakcan/peakcanbackend.cpp
parentd4ef6dcaf4eb9a65e928e8a94e1218ed6549ecad (diff)
Introduce an API for tracking the transferred frames
Note: There are no this implementation for the SocketCan plugin yet. Change-Id: I0b2ca92188f8784cebf046b033590c29c2ef3180 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/plugins/canbus/peakcan/peakcanbackend.cpp')
-rw-r--r--src/plugins/canbus/peakcan/peakcanbackend.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/plugins/canbus/peakcan/peakcanbackend.cpp b/src/plugins/canbus/peakcan/peakcanbackend.cpp
index d365bf4..2c4b83e 100644
--- a/src/plugins/canbus/peakcan/peakcanbackend.cpp
+++ b/src/plugins/canbus/peakcan/peakcanbackend.cpp
@@ -324,12 +324,12 @@ void PeakCanBackendPrivate::canWriteNotification()
{
Q_Q(PeakCanBackend);
- if (outgoingFrames.isEmpty()) {
+ if (!q->hasOutgoingFrames()) {
enableWriteNotification(false);
return;
}
- const QCanBusFrame frame = outgoingFrames.takeFirst();
+ const QCanBusFrame frame = q->dequeueOutgoingFrame();
const QByteArray payload = frame.payload();
TPCANMsg message;
@@ -344,13 +344,12 @@ void PeakCanBackendPrivate::canWriteNotification()
else
::memcpy(message.DATA, payload.constData(), sizeof(message.DATA));
- if (TPCANStatus st = ::CAN_Write(channelIndex, &message) != PCAN_ERROR_OK) {
+ if (TPCANStatus st = ::CAN_Write(channelIndex, &message) != PCAN_ERROR_OK)
q->setError(systemErrorString(st), QCanBusDevice::WriteError);
- } else {
- // TODO: Emit the future signal that the frame has been written
- }
+ else
+ emit q->framesWritten(qint64(1));
- if (!outgoingFrames.isEmpty())
+ if (q->hasOutgoingFrames())
enableWriteNotification(true);
}
@@ -508,7 +507,7 @@ bool PeakCanBackend::writeFrame(const QCanBusFrame &newData)
return false;
}
- d->outgoingFrames.append(newData);
+ enqueueOutgoingFrame(newData);
#if defined(Q_OS_WIN32)
d->enableWriteNotification(true);