diff options
author | Andre Hartmann <aha_1980@gmx.de> | 2016-04-30 08:00:52 +0200 |
---|---|---|
committer | André Hartmann <aha_1980@gmx.de> | 2016-06-24 10:50:14 +0000 |
commit | 55ad040de1ac6a33b4f2efe29038e97e8d43dbc2 (patch) | |
tree | e0d58669439d443fbdbc0000818a6d7fd170b89c /src/tools | |
parent | 0b0daef5bcf752da52183c318291c9e05d5ff3c6 (diff) |
QCanBusFrame: Add toString()
This allows to display CAN frames to the user and reduces a lot
of duplication.
[ChangeLog][QtSerialBus][QCanBusFrame] Added toString() to QCanBusFrame.
Task-number: QTBUG-53171
Change-Id: I56c4c8c41012f76e2db6e1c97307325b0c73b14a
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/canbusutil/readtask.cpp | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/src/tools/canbusutil/readtask.cpp b/src/tools/canbusutil/readtask.cpp index bb9b344..6c09e02 100644 --- a/src/tools/canbusutil/readtask.cpp +++ b/src/tools/canbusutil/readtask.cpp @@ -51,33 +51,13 @@ void ReadTask::checkMessages() { const QCanBusFrame frame = canDevice->readFrame(); - const qint32 id = frame.frameId(); - const qint8 dataLength = frame.payload().size(); - QString view; - if (frame.frameType() == QCanBusFrame::ErrorFrame) { + if (frame.frameType() == QCanBusFrame::ErrorFrame) view = canDevice->interpretErrorFrame(frame); - } else { - view += QLatin1String("Id: "); - view += QString::number(id, 16); - view += QLatin1String(" bytes: "); - view += QString::number(dataLength, 10); - view += QLatin1String(" data:"); - QByteArray array = frame.payload(); - for (int i=0; i < array.size(); i++) { - view += QLatin1String(" 0x"); - quint8 number = array[i]; - view += QString::number(number, 16); - } - } + else + view = frame.toString(); - if (frame.frameType() == QCanBusFrame::RemoteRequestFrame) { - output << "RTR: " << view << endl; - } else if (frame.frameType() == QCanBusFrame::ErrorFrame) { - output << "ERR: " << view << endl; - } else { - output << view << endl; - } + output << view << endl; } void ReadTask::receiveError(QCanBusDevice::CanBusError /*error*/) { |