canopen
canopen copied to clipboard
Problem with TPDO mapping
Hi Christan,
I tried to tpdo mapping to get voltage values from my Roboteq SBL1360A using socketcan bustype. Here's my code :
import canopen
network = canopen.Network()
node = canopen.RemoteNode(1, '/home/pc_stage/Downloads/roboteq_motor_controllers_v60.eds')
network.add_node(node)
network.connect(bustype='socketcan', channel='slcan0')
node.tpdo.read()
node.tpdo[1].clear()
node.tpdo[1].add_variable('Qry_VOLTS', 'V 5Vout') node.tpdo[1].cob_id = node.tpdo[1].predefined_cob_id node.tpdo[1].enabled = True
node.tpdo.save()
The last line isn't working, I get the following error :
Traceback (most recent call last):
File "tpdo.py", line 38, in
I don't know the range of what value is exceeded, therefore I can't save any configuration of the TPDO...
Thanks
Maxime
Hey, I'm having a similar problem.
Maybe you have a restriction on the upper bits of your cob_id parameter of the PDO.
In my case bit 31 enables/disables the PDO (standard) and bit 30 signals if RTR is allowed. But my device requires that bit 30 is always set. The way TPDOs are read and saved by the library causes problems with that.
Your stacktrace shows
self.com_record[1].raw = self.cob_id | PDO_NOT_VALID
the assignment resolves to sth. like
self.com_record[1].raw = self.cob_id & 0x1FFFFFFF | (1 << 31)
where you can see that all higher bits (except 31) are set to 0.
You are already using
node.tpdo[1].cob_id = node.tpdo[1].predefined_cob_id
after reading the tpdo. Maybe at that point you can inject the missing bits, if this is really your problem :)
Maybe checking what your "predefined_cob_id" actually is could also help :)