Skip to content

canopen.sdo.SdoCommunicationError: No SDO response received #44

@ZhVS

Description

@ZhVS

Hi!
I'm trying to start with your canopen python library, and I even can't make examples from git work without errors. :(

My code is a copy-paste one from example:

import canopen

# Start with creating a network representing one CAN bus
network = canopen.Network()

# Add some nodes with corresponding Object Dictionaries
node = network.add_node(6, 'd:\\MyDocs\\Libs\\py\\_work\\canopen-master\\test\\sample.eds')
network.add_node(7, 'd:\\MyDocs\\Libs\\py\\_work\\canopen-master\\test\\sample.eds')

# Connect to the CAN bus
# Arguments are passed to python-can's can.interface.Bus() constructor
# (see https://python-can.readthedocs.io/en/latest/bus.html).
#network.connect(bustype='socketcan', channel='can0')
# network.connect(bustype='kvaser', channel=0, bitrate=250000)
# network.connect(bustype='pcan', channel='PCAN_USBBUS1', bitrate=250000)
network.connect(bustype='virtual', channel=0, bitrate=250000, can_filters = None)
# network.connect(bustype='vector', app_name='CANalyzer', channel=0, bitrate=250000)
# network.connect(bustype='nican', channel='CAN0', bitrate=250000)

#network.scanner.search()

# Read a variable using SDO
device_name = node.sdo['Manufacturer device name'].raw
vendor_id = node.sdo[0x1018][1].raw

# Write a variable using SDO
node.sdo['Producer heartbeat time'].raw = 1000

# Read PDO configuration from node
node.pdo.read()
# Re-map TxPDO1
node.pdo.tx[1].clear()
node.pdo.tx[1].add_variable('Application Status', 'Status All')
node.pdo.tx[1].add_variable('Application Status', 'Actual Speed')
node.pdo.tx[1].trans_type = 254
node.pdo.tx[1].event_timer = 10
node.pdo.tx[1].enabled = True
# Save new PDO configuration to node
node.pdo.save()

# Transmit SYNC every 100 ms
network.sync.start(0.1)

# Change state to operational (NMT start)
node.nmt.state = 'OPERATIONAL'

# Read a value from TxPDO1
node.pdo.tx[1].wait_for_reception()
speed = node.pdo.tx[1]['Application Status.Actual Speed'].phys

# Disconnect from CAN bus
network.sync.stop()
network.disconnect()

eds file used in code I've got from canopen-master\test
And here is what a interpreter prints to console after runnig script

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Tools\WinPython-2.7.6.4\python-2.7.6\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 540, in runfile
    execfile(filename, namespace)
  File "D:/MyDocs/SDBCS/_Trash/CAN/can_first_steps.py", line 30, in <module>
    device_name = node.sdo['Manufacturer device name'].raw
  File "D:\Tools\WinPython-2.7.6.4\python-2.7.6\lib\site-packages\canopen\common.py", line 64, in raw
    value = self.od.decode_raw(self.data)
  File "D:\Tools\WinPython-2.7.6.4\python-2.7.6\lib\site-packages\canopen\common.py", line 24, in data
    return self.get_data()
  File "D:\Tools\WinPython-2.7.6.4\python-2.7.6\lib\site-packages\canopen\sdo.py", line 240, in get_data
    return self.sdo_node.upload(self.od.index, self.od.subindex)
  File "D:\Tools\WinPython-2.7.6.4\python-2.7.6\lib\site-packages\canopen\sdo.py", line 150, in upload
    with ReadableStream(self, index, subindex) as fp:
  File "D:\Tools\WinPython-2.7.6.4\python-2.7.6\lib\site-packages\canopen\sdo.py", line 369, in __init__
    response = sdo_client.request_response(request)
  File "D:\Tools\WinPython-2.7.6.4\python-2.7.6\lib\site-packages\canopen\sdo.py", line 118, in request_response
    return self.read_response()
  File "D:\Tools\WinPython-2.7.6.4\python-2.7.6\lib\site-packages\canopen\sdo.py", line 102, in read_response
    raise SdoCommunicationError("No SDO response received")
canopen.sdo.SdoCommunicationError: No SDO response received

The same errors I've got when used ixaat usb-to-can II module and changed a code to

network.connect(bustype='ixaat', channel=0, bitrate=250000, can_filters = None)

What am I doing wrong?

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions