mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 08:40:30 +08:00
fix(uavcannode): reply to RestartNode before resetting (#28966)
* fix(uavcannode): reply to RestartNode before resetting The handler slept 20 s and then reset without returning, so the response was never sent and the requester always reported the restart as failed. Reset from the node's one-shot timer instead, as BeginFirmwareUpdate already does. Assisted-by: Claude:claude-opus-5-5 * fix(uavcannode): save params before the reset timer fires Node params persist only through the deferred autosave, which can lag a set by up to 2 s, and board_reset() does not wait for it. With the reset now 1 s after the request, a param set shortly before a RestartNode was lost. The 20 s sleep used to cover that window. Assisted-by: Claude:claude-fable-5-1
This commit is contained in:
1 parent
42ce28a986
commit
29decda537
1 file changed
+9
-4
@@ -327,6 +327,8 @@ void UavcanNode::busevent_signal_trampoline()
|
||||
static void cb_reboot(const uavcan::TimerEvent &)
|
||||
{
|
||||
watchdog_pet();
|
||||
// Params persist only through the deferred autosave, which board_reset() does not wait for
|
||||
param_save_default(true);
|
||||
board_reset(0);
|
||||
}
|
||||
|
||||
@@ -613,10 +615,13 @@ class RestartRequestHandler: public uavcan::IRestartRequestHandler
|
||||
{
|
||||
bool handleRestartRequest(uavcan::NodeID request_source) override
|
||||
{
|
||||
PX4_INFO("UAVCAN: Restarting by request from %i\n", int(request_source.get()));
|
||||
usleep(20 * 1000 * 1000);
|
||||
board_reset(0);
|
||||
return true; // Will never be executed BTW
|
||||
PX4_INFO("UAVCAN: Restarting by request from %i", int(request_source.get()));
|
||||
|
||||
// The response is only sent after this returns, so reset from a timer
|
||||
UavcanNode *node = UavcanNode::instance();
|
||||
node->_reset_timer.setCallback(cb_reboot);
|
||||
node->_reset_timer.startOneShotWithDelay(uavcan::MonotonicDuration::fromMSec(1000));
|
||||
return true;
|
||||
}
|
||||
} restart_request_handler;
|
||||
|
||||
|
||||
Reference in new issue
Block a user