Skip to content

Commit 2832eaf

Browse files
Fix RxPDOs not working correctly
1 parent eebea7b commit 2832eaf

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

canopen/pdo.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,14 @@ def name(self):
213213
"""
214214
direction = "Tx" if self.cob_id & 0x80 else "Rx"
215215
map_id = self.cob_id >> 8
216+
if direction == "Rx":
217+
map_id -= 1
216218
node_id = self.cob_id & 0x7F
217219
return "%sPDO%d_node%d" % (direction, map_id, node_id)
218220

219221
def on_message(self, can_id, data, timestamp):
220-
if can_id == self.cob_id:
222+
is_transmitting = self.transmit_thread and self.transmit_thread.is_alive()
223+
if can_id == self.cob_id and not is_transmitting:
221224
with self.receive_condition:
222225
self.is_received = True
223226
self.data = data
@@ -344,6 +347,7 @@ def start(self, period=None):
344347

345348
if not self.period:
346349
raise ValueError("A valid transmission period has not been given")
350+
logger.info("Starting %s with a period of %s seconds", self.name, self.period)
347351

348352
if not self.transmit_thread or not self.transmit_thread.is_alive():
349353
self.stop_event.clear()

canopen/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
__version__ = "0.4.0.dev7"
2+
__version__ = "0.4.0.dev8"

0 commit comments

Comments
 (0)