UAVCAN execution in px4

I am working on integrating px4 with a freeRTOS system using UAVCAN. I have downloaded the latest firmware from git repository. I found an existing example of UAVCAN with esc. I have few questions regarding it.

From uavcan_main.cpp , two functions in esc.cpp is getting called. First function being
*void UavcanEscController::update_outputs(float outputs, unsigned num_outputs) which is working fine.

The other function being

void UavcanEscController::esc_status_sub_cb(const uavcan::ReceivedDataStructureuavcan::equipment::esc::Status &msg)
which is not getting executed at all. Am I missing any particular esc driver over here? if so, can someone please point me in the right direction.

Because when I built it, I build it with only uavcan driver and not with uavcanesc driver.

Is the above scenario is related to build and debug configurations?? cause i am not facing any error while building but the settings are not clearly mentioned for this in the documentation.

Is the above scenario happening cause of missing uavcan driver or esc driver cause I have written a similar function

void UavcanTeste::teste_receive_sub_cb(const

uavcan::ReceivedDataStructuruavcan::equipment::teste::TesteReceive &msg)
which has a new CAN message. But this function is also not getting executed like the above one inside esc.cpp

Is it becasue of the hardware dependency ? Cause I use qGroundControl and I have enabled “UAVCAN settings” and others as well. But When I initiate command
uavcan start” only update_outputs function from point 1 is getting executed ignoring esc_status_sub_cb from point 1.

Any pointers would be highly helpful. I tried all troubleshooting and looking into forums i could. But I am missing a file or a patch which I am not able to figure out.

Thank you

Thanks and Regards
Niranjan Ravi.

Hi Ravi,

I’m not sure exactly where you see esc_status_sub_cb being called, at least from the latest PX4 drivers/uavcan/actuators/esc.cpp file. The callback function gets setup in the init() function of UavcanEscController class and then the uORB topic gets copied in uavcan_main.cpp.

If I understand correctly, the uavcanesc driver is the driver for setting up an actual ESC device. Are you trying to set up this device as an ESC or are you trying to connect an ESC to it?

If you are trying to interface with another ESC, you need to make sure the UAVCAN ESC is publishing the status message.


Thank you for your reply. Yes, what you mentioned is correct.
void esc_status_sub_cb(const uavcan::ReceivedDataStructure uavcan::equipment::esc::Status> &msg); is a call-back function which gets setup in init()function of UavcanEscController class.

The application I am working on is, I am trying to get an input to px4 using uavcan from an external hardware device(a freeRTOS system). But I was not able to understand how to do it, so I looked into esc.cpp and esc.hpp files.
For this,

  1. I created a new CAN message called TesteReceive with a uint8_t variable inside it under uavcan/libuavcan/dsdl/uavcan/equipment folder.
  2. I also created my own teste_actuator.cpp and teste_actuator.hpp files under actuator folder like how it is done for ESC.
  3. Inside teste_actuator.cpp I created a function called

void UavcanTeste::teste_receive_sub_cb
(const uavcan::ReceivedDataStructure uavcan::equipment::teste::TesteReceive> &msg) which would look for incoming messages in the CAN port and display it. I also made this function as callback function and I am calling it from uavcan_main.cpp. [UavcanTeste is class like how UavcanEscController class is for ESC ]

But this function is never getting executed when I connect the can port of pixhawk with external freeRTOS system. I placed print statements inside this function but not working.

How do I make px4 receive an external input from other hardware using uavcan? i apologize if I am not making my explanation clear.

Any comments would help me a lot.

Thank you
Thanks and Regards

Are you sure that you are broadcasting the message?

If you have an SLCAN adapter, I would recommend using the UAVCAN GUI tool to monitor the messages on the CAN bus with your FreeRTOS node working. This will let you know whether there is an issue with receiving the message or sending the message.

If you don’t have an SLCAN node such as the Zubax Babel, I would highly recommend getting one as the UAVCAN GUI tool is indispensable when developing a UAVCAN application.


I’m going to ping @PavelKirienko, he might be able to help here.

Thank you for your inputs. Yes, I have placed an order for SLCAN adapter. I will check with adapter and get back if I have any issues.
Thank you
Thanks and Regards

Thank you for your inputs.

(types nervously - this is meant to help not offend).
If you have a Pixhawk for bench testing, you can use ArduPilot as an slcan or serial adapter these days, and avoid the need for a babel or ftdi when testing/configuring peripherals. It’s a pretty handy feature…
I’m not sure it’s documented, but is available in Master and Beta Missionplanner.


Hi ,
Yes, I tried with ardupilot but I was facing difficulty during testing since I am new to this. But, I would give it a try again. Thank you for your inputs.
Thanks and Regards

I think you misunderstood: the problem you have isn’t related to the flight stack. You can set a serial option to slcan in ArduPilot (Master), including the USB port. That enables use of the Pixhawk itself as an slcan adapter. Once you have the peripherals set up, use whatever flight stack you wish.

Yeah!! I think I got it now. So, irrespective of the flight stack i use i can setup a serial connection to slcan in ardupilot to check whether hardfault or where my code is failing.

I also noticed one thing in my code. I created a new DSDL file to send a data from pixhawk board to an external device(a freeRTOS system). I chose a new datatype id say 760 like this 760.SendData.uavcan which has an uint8 variable whose value will be updated every second [similar like how is written for esc 1030.RawCommand.uavcan]

Am I proceeding in a right manner? Is there any restrictions on how should I choose datatype id? I wish I had more understanding in above things.
Thank you.

1 Like

Yes, but I think there are some guidelines on which id’s are for custom use and which are part of the UAVCAN master. Check out the vendor-specific data types section here.

This is only a convention, but could prevent possible future conflicts. As long as nothing else is using 760 (I didn’t find any in a quick search of the standard data types page), it should work; it’s just not best practice.

Do you have this data type defined on both the Pixhawk and your custom device?

Also, you will need to put this definition in the DSDL for the UAVCAN GUI tool in order to properly interpret it using the bus monitor. There are instructions for how to do that here. Have you had any success in reading the message with the UAVCAN GUI tool?


Thank you for your inputs .

yes, I checked the guidelines like you mentioned. Since 760 was not previously used by firmware, I used it. I would be modifying it once I successfully complete this project. Yes, I have mentioned the data type in both pixhawk and my custom device.

I have placed an order for SLCAN adapter, I am yet to receive it. !

In the meantime, I tried something different. I connected my CAN high and low pins between these two devices to oscilloscope to verify if there are any signal changes.I could see signal lines when I initiate “uavcan start” .

But my custom device is not able to receive the value properly! It used FlexCAN. I am not sure why!!I am making required code changes now to make it work.

Thank you
Thanks and Regards

I tried testing it through SLCAN adapter. When I run my “uavcan start” command,

“Discovery not possible”- Local node is configured as an anonymous node. I tried loading different files but error persists.
Finally I received “Node failure” error and terminated.

I. I have created a data Type ID - 760
2. I have not mentioned any node id.

Am I missing something? Would be helpful if you could help me
Thank you

Have you tried to give your node an actual ID? I never run my nodes as anonymous, so I can’t help you with that.

I usually get the error you show in the screenshot when I unplug the SLCAN adapter or it somehow becomes disconnected. That just says that the SLCAN adapter is not working right. Does the UAVCAN tool work without your device connected?

1 Like

I tried setting a node ID for example 127 and many others. Still same. I am not able to fetch any data!
I even took a fresh patch from Git and tried to check with SLCAN adapter but could not visualize any results.

This is the screenshot for that:

No, UAVCAN tool did not work when my device is not connected.

I read through the documentation again. I am confused at two places.

  1. How do I choose the local node ID field in UAVCAN GUI tool. It takes vales from 0 to 127?
  2. The SLCAN adapter I am using is Zubax Babel. Does it support Pixhawk4 board ? Cause there is something else called Zubax GNSS.

From their documentation page :

Devices which are known to support UAVCAN peripherals:
• Pixhawk Autopilot Series (both PX4 and APM firmware): Pixhawk, Pixhawk 2 (Cube), Pixhawk 3 Pro, Pixhawk 4, Pixracer

Now I am not sure where there it is Zubax babel or zubax GNSS with pixhawk 4 board!
any pointers is much helpful? I am struck in same place for a long time!!
Thank you
Thanks and Regards

A couple of things:

  1. I usually accept the default local node ID of 127 for the GUI tool. Just make sure that you don’t try to use this ID again on any other devices as the protocol requires unique ID’s.

  2. You are using the correct device. The Zubax GNSS is exactly what it says it is: a GNSS (Global Navigation Satellite System) - not an SLCAN adapter. There is no special support for the Pixhawk with the Babel and none is needed. All that matters is that the UAVCAN protocol was properly implemented on any connected device.

  3. Have you checked to ensure that the baud rates are the same on the Pixhawk, your device, and the Babel? If not, perhaps check there.

  4. I’m not sure what you are expecting to get from the Pixhawk when you do a param fetch. I don’t have a pixhawk with me at the moment, or I would test this out myself. What are you expecting to see from this? Did you implement a response to the parameter fetch message on the Pixhawk or modify the one that is there (again, I’m not sure what to expect since I don’t have the device with me at the moment)?

  5. Try opening up the bus monitor and see what traffic is on the bus. This will contain any messages that are being sent. If you are trying to debug your device, there is no need to connect the Pixhawk. You can just directly connect your device to the SLCAN adapter. I would suggest implementing the status message if you have not already as it will see that your device is connected and working properly. Otherwise, just send some sort of data on the bus and observe through the bus monitor. It shows you the Hex values of your message so you can ensure the right data is being sent.


1 Like

Thank you for the help. I was able to visualize something now. With respect to the things you mentioned above.

  1. Yes, 127 was not used by anything else. I checked the protocol files. I used 127 as such.

  2. yes, babel worked fine now.

  3. yes, the baud rate is same as 115200 for my pixhawk and Babel.

  4. Yes, I was trying in a wrong way. i did not do any coding in firmware to make the param fetch. I was trying in a wrong manner.

  5. the bus monitor worked like a charm. I was so naive to miss these days. From my pixhawk I am sending data(integer) through CAN ID as 760 and I was able to see this in bus monitor.

I could see the CAN ID as 1002F801 but my data type shows as <unknown message 760> [unlike this format (the location for the file)] like how its showing up in example. Is it gonna be a problem ?

Many thanks for your valuable inputs.


I’m not sure what you are getting at. Is the data hex as you expect?

You definitely need to figure out how to get the GUI tool to recognize your custom command. I haven’t actually done that myself, but there are tutorials on the UAVCAN website on how to do that. It should be pretty straightforward. I think you have to specify the path to your file when you launch the GUI tool.


Yes, data hex is as expected.
Now I am able to send data from px4 and received data in px4 as well. Could see the values in Bus monitor during send and receive.
But I am not able to print and display the received values in qgroundControl. I have used a simple uorb function to subscribe and display the data. its not working properly.
Any other ways to show the received data in qgroundControl?
Thank you