Hi guys,
With the following script
# Hello World program in Python
import uavcan
# Instantiating an instance of standard service type uavcan.protocol.GetNodeInfo
# Here we need the response data structure, which is why we use the factory Response()
node_info = uavcan.protocol.GetNodeInfo.Response()
node_info.name = 'org.uavcan.pyuavcan_demo'
node_info.software_version.major = 1
node_info.hardware_version.unique_id = b'100' # Setting first 5 bytes; rest will be kept zero
# Fill other fields as necessary...
node = uavcan.make_node('can0',
node_id=100, # Setting the node ID 123
node_info=node_info) # Setting node info
def perform_other_tasks():
print('Periodic')
handle = node.add_handler(uavcan.protocol.NodeStatus, node_status_callback)
def node_status_callback(event):
print('NodeStatus message from node', event.transfer.source_node_id)
print('Node uptime:', event.message.uptime_sec, 'seconds')
# Messages, service requests, service responses, and entire events
# can be converted into YAML formatted data structure using to_yaml():
print(uavcan.to_yaml(event))
while True:
try:
node.spin(1) # Spin for 1 second or until an exception is thrown
perform_other_tasks()
# time.sleep(0.1) # Never do this!
except UAVCANException as ex:
print('Node error**********************************************:', ex)
I get the following error
Traceback (most recent call last):
File “test.py”, line 29, in
node.spin(1) # Spin for 1 second or until an exception is thrown
File “/usr/local/lib/python3.7/dist-packages/uavcan/node.py”, line 414, in spin
execute_once()
File “/usr/local/lib/python3.7/dist-packages/uavcan/node.py”, line 410, in execute_once
self._recv_frame(frame)
File “/usr/local/lib/python3.7/dist-packages/uavcan/node.py”, line 314, in _recv_frame
transfer.from_frames(transfer_frames)
File “/usr/local/lib/python3.7/dist-packages/uavcan/transport.py”, line 781, in from_frames
raise TransferError(“Toggle bit value {0} incorrect on frame {1}”.format(tail & 0x20, idx))
uavcan.transport.TransferError: Toggle bit value 0 incorrect on frame 1During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “test.py”, line 32, in
except UAVCANException as ex:
NameError: name ‘UAVCANException’ is not defined
I have to admit that I’m a beginner, so any help is appreciated.
Any idea?
Best regards,
Malis