Skip to content

Commit f5c6ae1

Browse files
committed
In stead of assigning 0 directly to a timestamp member, make it None, then check whether it exists before doing the subtraction. This way, we can potentially use other types for the timestamp, as long as subtracting two of them result in an integer/float (meaning seconds).
1 parent cdd7d51 commit f5c6ae1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

canopen/pdo/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def __init__(self, pdo_node, com_record, map_array):
174174
#: Current message data
175175
self.data = bytearray()
176176
#: Timestamp of last received message
177-
self.timestamp = 0
177+
self.timestamp = None
178178
#: Period of receive message transmission in seconds
179179
self.period = None
180180
self.callbacks = []
@@ -268,7 +268,7 @@ def on_message(self, can_id, data, timestamp):
268268
with self.receive_condition:
269269
self.is_received = True
270270
self.data = data
271-
self.period = timestamp - self.timestamp
271+
self.period = timestamp - self.timestamp if self.timestamp is not None else timestamp
272272
self.timestamp = timestamp
273273
self.receive_condition.notify_all()
274274
for callback in self.callbacks:

0 commit comments

Comments
 (0)