-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests and dbc for frame decoding
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
VERSION "created by canmatrix" | ||
|
||
|
||
NS_ : | ||
|
||
BS_: | ||
|
||
BU_: | ||
|
||
|
||
BO_ 1 testFrame1: 8 TEST_ECU | ||
SG_ sig0 : 1|2@0+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ sig1 : 7|6@0+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ sig2 : 15|11@0+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ sig3 : 20|12@0+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ sig4 : 24|9@0+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ sig5 : 50|3@0+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ sig6 : 53|3@0+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ sig7 : 47|10@0+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ sig8 : 58|3@0+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ sig9 : 61|3@0+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ sig10 : 63|2@0+ (1.0,0.0) [0|0] "" CCL_TEST | ||
|
||
BO_ 2 testFrame2: 8 TEST_ECU | ||
SG_ secSig1 : 60|2@1+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ secSig2 : 55|1@1+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ secSig3 : 20|4@1+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ secSig4 : 62|2@1+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ secSig5 : 34|3@1+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ secSig6 : 37|3@1+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ secSig7 : 59|1@1- (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ secSig8 : 56|3@1+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ secSig9 : 52|3@1+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ secSig10 : 8|12@1+ (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ secSig11 : 24|10@1- (1.0,0.0) [0|0] "" CCL_TEST | ||
SG_ secSig12 : 0|8@1+ (1.0,0.0) [0|0] "" CCL_TEST | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import pytest | ||
import canmatrix.formats | ||
|
||
|
||
def test_decode_from_dbc(): | ||
cm = canmatrix.formats.loadp("test_frame_decoding.dbc", flatImport = True) | ||
This comment has been minimized.
Sorry, something went wrong. |
||
# 001#8d00100100820100 | ||
frameData1 = bytes([141, 0, 16, 1, 0, 130, 1, 0]) | ||
|
||
# 002#0C00057003CD1F83 | ||
frameData2 = bytes([12, 0, 5, 112, 3, 205, 31, 131]) | ||
|
||
frame1 = cm.frameById(1) | ||
decoded1 = frame1.decode(frameData1) | ||
assert decoded1["sig0"] == 1 | ||
assert decoded1["sig1"] == 35 | ||
assert decoded1["sig2"] == 0 | ||
assert decoded1["sig3"] == 2048 | ||
assert decoded1["sig4"] == 256 | ||
assert decoded1["sig5"] == 1 | ||
assert decoded1["sig6"] == 0 | ||
assert decoded1["sig7"] == 520 | ||
assert decoded1["sig8"] == 0 | ||
assert decoded1["sig9"] == 0 | ||
assert decoded1["sig10"] == 0 | ||
|
||
frame2 = cm.frameById(2) | ||
decoded2 = frame2.decode(frameData2) | ||
assert decoded2["secSig1"] == 0 | ||
assert decoded2["secSig2"] == 0 | ||
assert decoded2["secSig3"] == 0 | ||
assert decoded2["secSig4"] == 2 | ||
assert decoded2["secSig5"] == 0 | ||
assert decoded2["secSig6"] == 0 | ||
assert decoded2["secSig7"] == 0 | ||
assert decoded2["secSig8"] == 3 | ||
assert decoded2["secSig9"] == 1 | ||
assert decoded2["secSig10"] == 1280 | ||
assert decoded2["secSig11"] == -144 | ||
assert decoded2["secSig12"] == 12 | ||
This comment has been minimized.
Sorry, something went wrong. |
1 comment
on commit 3e70b14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not fix #119 yet, but I'm quite sure, the expectations of this test is correct.
I tend to put something like this at the top of the file.
Then on this line you can
Otherwise this path would be referencing a file in the cwd?
And yes, we'd need the
pathlib2
backport ofpathlib
since we support py2.