Index: sources/canbus/caninterface.cpp =================================================================== diff -u -r4c53c7c62df7562a6c0915f0c5af7ea0ed884ca3 -r1732e83d2a0308b9c706f37d6d7724a364bbff2a --- sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision 4c53c7c62df7562a6c0915f0c5af7ea0ed884ca3) +++ sources/canbus/caninterface.cpp (.../caninterface.cpp) (revision 1732e83d2a0308b9c706f37d6d7724a364bbff2a) @@ -78,10 +78,14 @@ { if (_canDevice) { connect(_canDevice, SIGNAL( framesReceived()), - this , SLOT (onFrameReceive ())); + this , SLOT (onFrameReceive ())); connect(_canDevice, SIGNAL( errorOccurred(QCanBusDevice::CanBusError)), - this , SLOT (onError (QCanBusDevice::CanBusError))); + this , SLOT (onFrameError (QCanBusDevice::CanBusError))); + + connect(_canDevice, SIGNAL( framesWritten(qint64)), + this , SLOT (onFrameWrittern(qint64))); + } connect(_MessageHandler, SIGNAL(didFrameTransmit(QCanBusFrame)), this , SLOT( onFrameTransmit(QCanBusFrame))); @@ -116,14 +120,13 @@ * \details send a frame over the CAN Bus * \param vFrame CAN message frame */ -void CanInterface::transmit(const QCanBusFrame &vFrame) +bool CanInterface::transmit(const QCanBusFrame &vFrame) { if( !_canDevice ) - return; - _canDevice->writeFrame(vFrame); -} + return false; + return _canDevice->writeFrame(vFrame);} -void CanInterface::consoleout(const QCanBusFrame &vFrame, const QString &vView) +void CanInterface::consoleOut(const QCanBusFrame &vFrame, const QString &vView) { const QString time = QString::fromLatin1("%1.%2 ") .arg(vFrame.timeStamp().seconds(), 10, 10, QLatin1Char(' ')) @@ -173,7 +176,7 @@ * \details Can Bus error handler which sets the can status description * \param vError CanBus error */ -void CanInterface::onError(QCanBusDevice::CanBusError vError) +void CanInterface::onFrameError(QCanBusDevice::CanBusError vError) { switch (vError) { case QCanBusDevice::ReadError: @@ -186,10 +189,24 @@ default: break; } - emit didError(_canStatus); + emit didFrameError(_canStatus); } /*! + * \brief CanInterface::onFrameWrittern + * \details This is the slot connected to the signal + * which is emitted every time a payload of frames + * has been written to the CAN bus. + * \param vFramesCount The framesCount argument is set to the number of frames + * that were written in this payload. + */ +void CanInterface::onFrameWrittern(qint64 /*vFramesCount*/) +{ + //_numberFramesWritten = vFramesCount; + //qDebug() << "onFrameWrittern::FramesCount : " << vFramesCount; +} + +/*! * \brief CanInterface onRead * \details CanBus read handler */ @@ -201,17 +218,18 @@ while (_canDevice->framesAvailable()) { const QCanBusFrame frame = _canDevice->readFrame(); - QString view; - if (frame.frameType() == QCanBusFrame::ErrorFrame) { - view = _canDevice->interpretErrorFrame(frame); + if (_consoleOutEnabled) { + QString view; + if (frame.frameType() == QCanBusFrame::ErrorFrame) { + view = _canDevice->interpretErrorFrame(frame); + } + else { + view = frame.toString(); + } + consoleOut(frame, view); } - else { - view = frame.toString(); - } - //consoleout(frame, view); - - emit didRead(frame); + emit didFrameReceive(frame); } } @@ -223,6 +241,6 @@ */ void CanInterface::onFrameTransmit(const QCanBusFrame &vFrame) { - // TODO : Process Frame - transmit(vFrame); + bool ok = transmit(vFrame); + emit didFrameTransmit(ok); }