diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2015-09-03 12:39:10 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2015-09-06 06:03:43 +0000 |
commit | d4ef6dcaf4eb9a65e928e8a94e1218ed6549ecad (patch) | |
tree | dd162ffe9b0e1136f85abfd7a5bab5062817eea1 /src/plugins/canbus/tinycan/tinycanbackend.cpp | |
parent | 304c1da155996d41bd847d9aeaa2405076cae30f (diff) |
Optimize the CAN frames receiving
We do not need to emit a signal when each frame is received,
this increases the load of the event loop. The input FIFO can
contains more than one frame, thus we only need to emit the
signal when all current frames were read.
In this case this signal is renamed to framesReceived instead
of frameReceived.
Change-Id: If97cfd4304dae9549748f87dbd0b54eae4c0a0f2
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/plugins/canbus/tinycan/tinycanbackend.cpp')
-rw-r--r-- | src/plugins/canbus/tinycan/tinycanbackend.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/plugins/canbus/tinycan/tinycanbackend.cpp b/src/plugins/canbus/tinycan/tinycanbackend.cpp index 300c4d4..a599ebf 100644 --- a/src/plugins/canbus/tinycan/tinycanbackend.cpp +++ b/src/plugins/canbus/tinycan/tinycanbackend.cpp @@ -331,6 +331,8 @@ void TinyCanBackendPrivate::canReadNotification() { Q_Q(TinyCanBackend); + QVector<QCanBusFrame> newFrames; + forever { if (!::CanReceiveGetCount(channelIndex)) break; @@ -364,8 +366,10 @@ void TinyCanBackendPrivate::canReadNotification() frame.setExtendedFrameFormat(message.Flags.Flag.EFF); frame.setFrameType(message.Flags.Flag.RTR ? QCanBusFrame::RemoteRequestFrame : QCanBusFrame::DataFrame); - q->enqueueReceivedFrame(frame); + newFrames.append(frame); } + + q->enqueueReceivedFrames(newFrames); } void TinyCanBackendPrivate::startupDriver() |