Skip to content

Commit 484c22d

Browse files
Fix debug logging not working in some cases
Fixes #58.
1 parent 8b6c35a commit 484c22d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

canopen/pdo/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ def name(self):
251251
Examples:
252252
* TxPDO1_node4
253253
* RxPDO4_node1
254+
* Unknown
254255
"""
256+
if not self.cob_id:
257+
return "Unknown"
255258
direction = "Tx" if self.cob_id & 0x80 else "Rx"
256259
map_id = self.cob_id >> 8
257260
if direction == "Rx":
@@ -519,8 +522,8 @@ def set_data(self, data):
519522
:param bytes data: Value for the PDO variable in the PDO message as :class:`bytes`.
520523
"""
521524
byte_offset, bit_offset = divmod(self.offset, 8)
522-
logger.debug("Updating %s to %s in message 0x%X",
523-
self.name, binascii.hexlify(data), self.pdo_parent.cob_id)
525+
logger.debug("Updating %s to %s in %s",
526+
self.name, binascii.hexlify(data), self.pdo_parent.name)
524527

525528
if bit_offset or self.length % 8:
526529
cur_msg_data = self.pdo_parent.data[byte_offset:byte_offset + len(self.od) // 8]

0 commit comments

Comments
 (0)