summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2016-05-12 11:25:00 +0200
committerAndré Hartmann <aha_1980@gmx.de>2016-05-18 09:44:49 +0000
commitf52530dbf1070613481b24b1a0d31565cd759bc7 (patch)
treec79596196a2367b523f956b084b823c19f323b5f /tests
parentb8d5c1f1dff57da6927470543e5d004c237846ac (diff)
QCanFrame: Fix constructing frames with extended ID < 0x800
While frames with an CAN-ID > 0x7FF always require the extended format, the opposite is not true for frames with an ID <= 0x7FF. From CAN bus side, the following CAN frames are both valid, not equal from CAN ID side, and do not lead to bus collisons (as they would do, if both were in standard format): 123 [8] 11 22 33 44 55 66 77 88 00000123 [5] 44 33 22 11 00 Introduced with 23e54b294d3e96a669fff16f2f5343373fb6010a Task-number: QTBUG-53171 Change-Id: I3412b5980ecaab649bfcb493c952a888f5a90394 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qcanbusframe/tst_qcanbusframe.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/qcanbusframe/tst_qcanbusframe.cpp b/tests/auto/qcanbusframe/tst_qcanbusframe.cpp
index a25a08b..eb427fb 100644
--- a/tests/auto/qcanbusframe/tst_qcanbusframe.cpp
+++ b/tests/auto/qcanbusframe/tst_qcanbusframe.cpp
@@ -98,17 +98,25 @@ void tst_QCanBusFrame::id()
{
QCanBusFrame frame;
QVERIFY(!frame.frameId());
+ frame.setExtendedFrameFormat(false);
frame.setFrameId(2047u);
QCOMPARE(frame.frameId(), 2047u);
QVERIFY(frame.hasExtendedFrameFormat() == false);
// id > 2^11 -> extended format
+ frame.setExtendedFrameFormat(false);
frame.setFrameId(2048u);
QCOMPARE(frame.frameId(), 2048u);
QVERIFY(frame.hasExtendedFrameFormat() == true);
// id < 2^11 -> no extended format
+ frame.setExtendedFrameFormat(false);
frame.setFrameId(512u);
QCOMPARE(frame.frameId(), 512u);
QVERIFY(frame.hasExtendedFrameFormat() == false);
+ // id < 2^11 -> keep extended format
+ frame.setExtendedFrameFormat(true);
+ frame.setFrameId(512u);
+ QCOMPARE(frame.frameId(), 512u);
+ QVERIFY(frame.hasExtendedFrameFormat() == true);
}
void tst_QCanBusFrame::payload()