FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-can/test/zero_dlc_test.py at develop · feuerball/python-can · GitHub
feuerball
/
python-can
Public
forked from
hardbyte/python-can
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-can
/
test
/
zero_dlc_test.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (33 loc) · 1.32 KB
Breadcrumbs
python-can
/
test
/
zero_dlc_test.py
Copy path
File metadata and controls
49 lines (33 loc) · 1.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
"""
"""
from
time
import
sleep
import
unittest
import
logging
import
can
logging
.
getLogger
(
__file__
).
setLevel
(
logging
.
DEBUG
)
class
ZeroDLCTest
(
unittest
.
TestCase
):
def
test_recv_non_zero_dlc
(
self
):
bus_send
=
can
.
interface
.
Bus
(
interface
=
"virtual"
)
bus_recv
=
can
.
interface
.
Bus
(
interface
=
"virtual"
)
data
=
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
]
msg_send
=
can
.
Message
(
is_extended_id
=
False
,
arbitration_id
=
0x100
,
data
=
data
)
bus_send
.
send
(
msg_send
)
msg_recv
=
bus_recv
.
recv
()
# Receiving a frame with data should evaluate msg_recv to True
self
.
assertTrue
(
msg_recv
)
def
test_recv_none
(
self
):
bus_recv
=
can
.
interface
.
Bus
(
interface
=
"virtual"
)
msg_recv
=
bus_recv
.
recv
(
timeout
=
0
)
# Receiving nothing should evaluate msg_recv to False
self
.
assertFalse
(
msg_recv
)
def
test_recv_zero_dlc
(
self
):
bus_send
=
can
.
interface
.
Bus
(
interface
=
"virtual"
)
bus_recv
=
can
.
interface
.
Bus
(
interface
=
"virtual"
)
msg_send
=
can
.
Message
(
is_extended_id
=
False
,
arbitration_id
=
0x100
,
data
=
[])
bus_send
.
send
(
msg_send
)
msg_recv
=
bus_recv
.
recv
()
# Receiving a frame without data (dlc == 0) should evaluate msg_recv to True
self
.
assertTrue
(
msg_recv
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Back
|
FazBrowse Home
|
New Git URL