Homepage GitHub

Hardfault when broadcast 2 differerent messages at once


(Sergey Radkov) #1
			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;

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

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>.

linked_list.hpp:126
if (root_ == UAVCAN_NULLPTR || predicate(root_))

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


(Pavel Kirienko) #2

Please increase your stack and see if the problem persists.


(Sergey Radkov) #3

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.


(Pavel Kirienko) #4

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/


(Sergey Radkov) #5

Thanks! It seems the reason was exactly that.