@@ -113,11 +113,11 @@ The :code:`n` is the PDO index (normally 1 to 4). The second form of access is f
113113 # network.connect(bustype='nican', channel='CAN0', bitrate=250000)
114114
115115 # Read a variable using SDO
116- device_name = node.sdo[' Manufacturer device name' ].raw
117- vendor_id = node.sdo[0x 1018 ][1 ].raw
116+ device_name = node.sdo[' Manufacturer device name' ].get_raw()
117+ vendor_id = node.sdo[0x 1018 ][1 ].get_raw()
118118
119119 # Write a variable using SDO
120- node.sdo[' Producer heartbeat time' ].raw = 1000
120+ node.sdo[' Producer heartbeat time' ].set_raw( 1000 )
121121
122122 # Read PDO configuration from node
123123 node.tpdo.read()
@@ -141,8 +141,8 @@ The :code:`n` is the PDO index (normally 1 to 4). The second form of access is f
141141
142142 # Read a value from TPDO[1]
143143 node.tpdo[1 ].wait_for_reception()
144- speed = node.tpdo[1 ][' Velocity actual value' ].phys
145- val = node.tpdo[' Some group.Some subindex' ].raw
144+ speed = node.tpdo[1 ][' Velocity actual value' ].get_phys()
145+ val = node.tpdo[' Some group.Some subindex' ].get_raw()
146146
147147 # Disconnect from CAN bus
148148 network.sync.stop()
@@ -195,17 +195,15 @@ This library can be used with asyncio.
195195
196196 async def main ():
197197
198- # Open CAN bus
198+ # Start with creating a network representing one CAN bus
199+ network = canopen.Network()
200+
201+ # Connect to the CAN bus
199202 # Arguments are passed to python-can's can.Bus() constructor
200203 # (see https://python-can.readthedocs.io/en/latest/bus.html).
201- bus = can.BUS(interface = ' pcan' , bitrate = 1000000 )
202-
203- # Create a network representing one CAN bus
204- network = canopen.Network(bus)
205-
206- # Start the notifier to enable canopen to respond to incoming CAN message
204+ # Note the loop parameter to enable asyncio operation
207205 loop = asyncio.get_event_loop()
208- network.notifier = can.Notifier(bus, network.listeners, 1 , loop = loop)
206+ network.connect( interface = ' pcan ' , bitrate = 1000000 , loop = loop)
209207
210208 # Create two independent tasks for two nodes 51 and 52 which will run concurrently
211209 task1 = asyncio.create_task(my_node(network, 51 , ' /path/to/object_dictionary.eds' ))
0 commit comments