I am trying to get can information using the following scripts but it does not receive and print response 1 and response 2:
connection=mavutil.mavlink_connection(‘udpin:192.168.0.2:14541’)
connection.wait_heartbeat()
message=connection.mav.command_long_encode(connection.target_system, connection.target_component, mavutil.mavlink.MAV_CMD_UAVCAN_GET_NODE_INFO, 0, 0, 0, 0, 0, 0, 0)
print(‘Message Encoded’)
connection.mav.send(message)
print(‘Message Delivered!’)
response_1=connection.recv_match(type=‘UAVCAN_NODE_INFO’, blocking=True)
response_2=connection.recv_match(type=‘UAVCAN_NODE_STATUS’, blocking=True)
print(response_1)
print(response_2)
The last thing above code prints is Message Delivered!
and keeps waiting for these messages to be received.
So, instead of type=‘UAVCAN_NODE_INFO’, I did type=‘COMMAND_ACK’
which gave me:
COMMAND_ACK {command: 5200, result: 3, progress: 0, result_param2: 0, target_system: 255, target_component: 0}
So, I went on Messages (common) · MAVLink Developer Guide
From here I got to know that PX4 does not support “MV_CMD_UAVCAN_GET_NODE_INFO”, Can you suggest me what is the alternative available? I couldn’t find any on above link.
And when I was going through all the px4 firmware folders, I found that after typing uavcan status in MAVLink Console it uses Health.1.0.uavcan, ID.1.0.uavcan and Mode.1.0.uavcan which is defined in (PX4-Autopilot/src/drivers/cyphal/legacy_data_types/uavcan/node) to print CAN interface and its properties.
From where I can learn to use these kind of messages in python script?
How can I write my own uavcan messages and use it?
I just want to know using python script that, If I have connected airspeed sensor or magnetormetor at a CAN1 and CAN2, how can I know if it is detecting the particular sensor, if yes what is the Node ID, Health and Mode?
If you are just interested in a particular type of thing, such as a UAVCAN battery, then you can probably look at the associated mavlink messages for that thing - i.e. I am fairly sure that a UAVCAN battery might be exposed via MAVLink.
If you need generic information as provided by these node messages then you’d have to write code to implement them. I don’t know enough about CAN to know how hard that would be. But I suspect not particularly hard.
Thank you for your help and all the information given.
Sorry that I had posted about CAN in this area but I couldn’t find any dedicated topic for it and thought it might be relevant to put under the current topic.
In case, I am able to find out more about this and also, have a solution, I will update it here for everyone to have a look.