Skip to content

Commit

Permalink
Update canopen/pdo/base.py:
Browse files Browse the repository at this point in the history
- additional logging on enabling pdo
- minor formatting options
  • Loading branch information
friederschueler authored and Frieder Schüler committed Jun 5, 2024
1 parent b2fa0bb commit b470a0a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions canopen/pdo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ def _raw_from(param):
subindex = (value >> 8) & 0xFF
# Ignore the highest bit, it is never valid for <= 64 PDO length
size = value & 0x7F
if getattr(self.pdo_node.node, "curtis_hack", False): # Curtis HACK: mixed up field order
if getattr(self.pdo_node.node, "curtis_hack", False):
# Curtis HACK: mixed up field order
index = value & 0xFFFF
subindex = (value >> 16) & 0xFF
size = (value >> 24) & 0x7F
Expand All @@ -371,7 +372,7 @@ def _raw_from(param):
def save(self) -> None:
"""Save PDO configuration for this map using SDO."""
if self.cob_id is None:
logger.debug("Skipping %s: no cob-id set", self.com_record.od.name)
logger.info("Skip saving %s: COB-ID was never set", self.com_record.od.name)
return
logger.info("Setting COB-ID 0x%X and temporarily disabling PDO", self.cob_id)
self.com_record[1].raw = self.cob_id | PDO_NOT_VALID | (RTR_NOT_ALLOWED if not self.rtr_allowed else 0x0)
Expand Down Expand Up @@ -422,7 +423,9 @@ def save(self) -> None:
self._update_data_size()

if self.enabled:
self.com_record[1].raw = self.cob_id | (RTR_NOT_ALLOWED if not self.rtr_allowed else 0x0)
cob_id = self.cob_id | (RTR_NOT_ALLOWED if not self.rtr_allowed else 0x0)
logger.info("Setting COB-ID 0x%X and re-enabling PDO", cob_id)
self.com_record[1].raw = cob_id
self.subscribe()

def subscribe(self) -> None:
Expand Down

0 comments on commit b470a0a

Please sign in to comment.