Skip to content

Commit a5e479a

Browse files
committed
Allow a non-zero data link count where no data is passed in.
1 parent 2446729 commit a5e479a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

can/message.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class Message(object):
66
"""
7-
Represents a CAN message.
7+
The :class:`~can.Message` object is used to represent CAN messages for both sending and receiving.
88
"""
99

1010
def __init__(self, timestamp=0.0, is_remote_frame=False, extended_id=True,
@@ -22,17 +22,16 @@ def __init__(self, timestamp=0.0, is_remote_frame=False, extended_id=True,
2222

2323
if data is None:
2424
self.data = bytearray()
25-
self.dlc = 0
2625
else:
2726
try:
2827
self.data = bytearray(data)
2928
except TypeError:
3029
logger.error("Couldn't create message from %r (%r)", data, type(data))
3130

32-
if dlc is None:
33-
self.dlc = len(self.data)
34-
else:
35-
self.dlc = dlc
31+
if dlc is None:
32+
self.dlc = len(self.data)
33+
else:
34+
self.dlc = dlc
3635

3736
assert self.dlc <= 8, "data link count was {} but it must be less than or equal to 8".format(self.dlc)
3837

0 commit comments

Comments
 (0)