Open GIT1RWM2AR opened 1 year ago
Hi. I know this is over a year past, but if you're still curious to find out what's not working, you could try to download the latest branch. I just did a refactoring of the whole SDO client logic. I removed the parallel implementation I used to have and are now using the same as official canopen, so you might be more successful if you retry now.
Hello to everyone, hello Svein,
I have tried to adapt your example to work with my configuration. I ran into a timeout-error even the motor-node is responding. Setting the RESPONSE_TIMEOUT = 1.5 seconds is no workaround. Any help will be appreciated.
Thank you in advance.
First I show the error, than the $candump -td slcan0, than the modified Phyton-Code: (marked error-lined with: -----> ) At the end I add some code, where I tried to use an USB-PCAN-Dongle from company PEAK; but I ran into the same SDO-Timeout-Error
The last executed program-lines:
The debugger-output:
File "/usr/lib/python3.10/asyncio/queues.py", line 159, in get await getter asyncio.exceptions.CancelledError During handling of the above exception, another exception occurred:
File "/usr/lib/python3.10/asyncio/tasks.py", line 456, in wait_for return fut.result()
asyncio.exceptions.CancelledError The above exception was the direct cause of the following exception: File "/home/ar/.local/lib/python3.10/site-packages/canopen/sdo/client.py", line 115, in aread_response response = await asyncio.wait_for( File "/usr/lib/python3.10/asyncio/tasks.py", line 458, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError During handling of the above exception, another exception occurred: File "/home/ar/Schreibtisch/WING-Test-3/CANopen-Async-IO-2023-05-01.py", line 96, in
main()
File "/home/ar/Schreibtisch/WING-Test-3/CANopen-Async-IO-2023-05-01.py", line 93, in main
asyncio.run(amain())
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/home/ar/Schreibtisch/WING-Test-3/CANopen-Async-IO-2023-05-01.py", line 86, in amain
await asyncio.gather(
File "/home/ar/Schreibtisch/WING-Test-3/CANopen-Async-IO-2023-05-01.py", line 21, in do_loop
await node.tpdo.aread()
File "/home/ar/.local/lib/python3.10/site-packages/canopen/pdo/base.py", line 67, in aread
await pdo_map.aread(from_od=from_od)
File "/home/ar/.local/lib/python3.10/site-packages/canopen/pdo/base.py", line 430, in aread
value = await var.aget_raw()
File "/home/ar/.local/lib/python3.10/site-packages/canopen/variable.py", line 91, in aget_raw
return self._get_raw(await self.aget_data())
File "/home/ar/.local/lib/python3.10/site-packages/canopen/sdo/base.py", line 162, in aget_data
return await self.sdo_node.aupload(self.od.index, self.od.subindex)
File "/home/ar/.local/lib/python3.10/site-packages/canopen/sdo/client.py", line 219, in aupload
async with await self.aopen(index, subindex, buffering=0) as fp:
File "/home/ar/.local/lib/python3.10/site-packages/canopen/sdo/client.py", line 402, in aopen
raw_stream = await AReadableStream.open(self, index, subindex)
File "/home/ar/.local/lib/python3.10/site-packages/canopen/sdo/client.py", line 550, in open
response = await sdo_client.arequest_response(request)
File "/home/ar/.local/lib/python3.10/site-packages/canopen/sdo/client.py", line 151, in arequest_response
return await self.aread_response()
File "/home/ar/.local/lib/python3.10/site-packages/canopen/sdo/client.py", line 118, in aread_response
raise SdoCommunicationError("No SDO response received")
canopen.sdo.exceptions.SdoCommunicationError: No SDO response received
The candump-output: --> ~4ms SDO-Responce-Time: ?? Why is the SDO responce is not received ??
(000.046334) slcan0 70A [1] 7F (002.848479) slcan0 607 [8] 40 00 18 01 00 00 00 00 Node:0x07: SDO: 0x1800.01 Request (000.003872) slcan0 587 [8] 43 00 18 01 87 01 00 00 Node:0x07: SDO: 0x1800.01 Responce: 3.87ms after Request (000.101092) slcan0 707 [1] 7F (000.004045) slcan0 60A [8] 40 00 18 01 00 00 00 00 Node:0x0A: SDO: 0x1800.01 Request (000.003953) slcan0 58A [8] 43 00 18 01 8A 01 00 00 Node:0x0a: SDO: 0x1800.01 Responce: 3.95ms after Request (000.038419) slcan0 70A [1] 7F (001.351532) slcan0 607 [8] 80 00 00 00 00 00 04 05 (001.602012) slcan0 707 [1] 7F
Your example: Adapted to my physical hardware-setting: Node: 7 and Node 0x0A
Python-Source-Code:
Example for PEAK-USB-CAN-Dongle:
on Linux-Mint-Command-Line: ip link set can0 up type can bitrate 500000
Python-Example; changed to socketcan and can0 to use PEAK-USB-CAN-Dongle:
async def amain(): bus = can.Bus(interface='socketcan', channel='can0', recieve_own_messages=True) network = canopen.Network() network.bus = bus ..... .....