Homepage GitHub

Hardfault when broadcast 2 differerent messages at once

			uavcan::equipment::actuator::Status msg;
			msg.actuator_id = actuator_id;
			msg.position = actuator_status_data.position;
			msg.force = actuator_status_data.force;
			msg.speed = actuator_status_data.speed;
			msg.power_rating_pct = actuator_status_data.power_rating_pct;

			uavcan::equipment::device::Temperature msg;
			msg.device_id = node_id;
			float temp = temperature_calculation(temperature_adc_value,THERMISTOR_B_COEFFICIENT,4095);
			msg.temperature = temp;

If I leave only one message, then everything works fine.
Period of shippment this messaes 50 ms.
The probability of falling depends on the workload of the CAN bus.

Hardfault analysis always indicates:

Line 126 of "../../src/drivers/uavcan/libuavcan/./libuavcan/include/uavcan/util/linked_list.hpp"
   starts at address 0x803f4ba <uavcan::CanTxQueue::push(uavcan::CanFrame const&, uavcan::MonotonicTime, uavcan::CanTxQueue::Qos, unsigned short)+288>
   and ends at 0x803f4be <uavcan::CanTxQueue::push(uavcan::CanFrame const&, uavcan::MonotonicTime, uavcan::CanTxQueue::Qos, unsigned short)+292>.

if (root_ == UAVCAN_NULLPTR || predicate(root_))

What can be wrong and how can you overcome this problem?

Please increase your stack and see if the problem persists.

Yes, I have previously increased the Hpwork stack (in which this code is executed). Increased and uavcan process stack.
Now I’ve increased it more, and now 8kb stacks, but the problem remains.

Your problem is caused by unsynchronized access to libuavcan from different threads. The library does not support this, please execute all your logic from one thread or use sub-nodes as described in the tutorial: https://uavcan.org/Implementations/Libuavcan/Tutorials/12._Multithreading/

Thanks! It seems the reason was exactly that.