Guard against race condition with targetReached
Test And Build / Lint (push) Failing after 4s
Test And Build / Build (push) Successful in 8s

This commit is contained in:
2026-06-09 13:36:51 +02:00
parent df7a15eeb2
commit d94341e1c0
+10 -4
View File
@@ -532,9 +532,9 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
} else {
// If we wait for a handshake, but the motor was moving in its last poll
// cycle and has reached its target, it is not moving. Otherwise it is
// considered moving, even if we're still waiting for the handshake.
// If the motor hasn't moved after being enabled, we cannot trust
// targetReached. Hence, the targetReachedUninitialized flag guards
// against invalid detection of the "moving" status.
if (pMasterMacsA_->targetReachedUninitialized) {
*moving = false;
} else {
@@ -545,7 +545,13 @@ asynStatus masterMacsAxis::doPoll(bool *moving) {
}
}
if (targetReached()) {
// If the motor is not switched on, the targetReached bit is set to
// true. targetReachedUninitialized is set to true in the enable
// function, which is in a separate thread than doPoll. Therefore,
// doPoll can reset targetReachedUninitialized, which then can lead to
// a false "moving" status. Therefore, we only trust targetReached if
// the motor is switched on.
if (targetReached() && switchedOn()) {
pMasterMacsA_->targetReachedUninitialized = false;
}
}