Skip to content

Commit 1a21371

Browse files
authored
added fallback in statusword property, resolves #168
Enable the statusword to get the value from the driver even if it's not configured in the TPDOS through the SDO mechanism.
1 parent a4dfbee commit 1a21371

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

canopen/profiles/p402.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,14 @@ def on_TPDOs_update_callback(self, mapobject):
369369
@property
370370
def statusword(self):
371371
"""Returns the last read value of the Statusword (0x6041) from the device.
372-
:raise ValueError: The Object 0x6041 (Statusword) is not configured in this device.
372+
If the the object 0x6041 is not configured in any TPDO it will fallback to the SDO mechanism
373+
and try to tget the value.
373374
"""
374375
try:
375376
return self.tpdo_values[0x6041]
376377
except KeyError:
377-
raise KeyError('The object 0x6041 (Statusword) is not configured in this device.')
378+
logger.warning('The object 0x6041 is not supported by the PDO mechanism, fallback to SDO')
379+
return self.sdo[0x6041].raw = value
378380

379381
@property
380382
def controlword(self):

0 commit comments

Comments
 (0)