Active monitor implementation on STM32

Hello!
I want to use example “Active monitor” from chapter “Node discovery” of libuavcan tutorial (https://uavcan.org/Implementations/Libuavcan/Tutorials/9._Node_discovery/) on my MCU STM32F103.

I add code from example and my project was builded successful. In debugging mode I check starting of retriever and adding listener and has no errors.

But monitoring is not work - collector.getNodeInfo(i) return nullptr for correct node id.
My mcu connected to pixhawk and i see can bus traffic by means of usb oscilloscope and I not see GetNodeInfo request.

May be someone know what is it?

Let’s have a look at your code.

I create uavcan_node.cpp (is attached) for working with uavcan in my project. In this file I use class NodeMonitor from example. In main function I call

uavcan_node::configureNode();

and in while infinite loop I call

uavcan_node::NodeSpin();

uavcan_node.cpp (13.9 KB)

The instance of NodeInfoRetriever is destroyed when the initialization function exits. You have to ensure proper object lifetimes: https://en.cppreference.com/w/cpp/language/lifetime

Thank You, Pavel! You absolutely right!