tests: homing: improve SimulateIdlerHoming

Add handling for HomingFailed which can cause the tests
to timeout.

Add checks for HomeForward and HomeBack
pull/344/head
Guðni Már Gilbert 2024-12-27 18:13:19 +00:00
parent e2c866166d
commit 71604443b0
1 changed files with 17 additions and 0 deletions

View File

@ -59,6 +59,18 @@ void SimulateIdlerAndSelectorHoming(logic::CommandBase &cb) {
void SimulateIdlerHoming(logic::CommandBase &cb) {
uint32_t idlerStepsFwd = mm::unitToSteps<mm::I_pos_t>(config::idlerLimits.lenght - 5.0_deg);
// Sometimes the initial idler state is Ready. Let's wait for the firmware to start
// homing.
REQUIRE(WhileCondition(
cb,
[&](uint32_t) { return mi::idler.State() == mm::MovableBase::Ready; },
5000));
// At this point the idler should always be homing forward.
REQUIRE((int)mi::idler.State() == (int)mm::MovableBase::HomeForward);
// Simulate the idler steps in one direction (forward)
for (uint32_t i = 0; i < idlerStepsFwd; ++i) {
main_loop();
cb.Step();
@ -69,6 +81,8 @@ void SimulateIdlerHoming(logic::CommandBase &cb) {
cb.Step();
mm::motion.StallGuardReset(mm::Idler);
REQUIRE((int)mi::idler.State() == (int)mm::MovableBase::HomeBack);
// now do a correct amount of steps of each axis towards the other end
uint32_t idlerSteps = mm::unitToSteps<mm::I_pos_t>(config::idlerLimits.lenght);
uint32_t maxSteps = idlerSteps + 1;
@ -83,6 +97,9 @@ void SimulateIdlerHoming(logic::CommandBase &cb) {
mm::motion.StallGuardReset(mm::Idler);
}
}
// If the homing has failed, the axis length was too short.
REQUIRE(!((mi::idler.State() & mm::MovableBase::HomingFailed) == mm::MovableBase::HomingFailed));
}
void SimulateIdlerWaitForHomingValid(logic::CommandBase &cb) {