diff --git a/src/emc/motion/homing.c b/src/emc/motion/homing.c index a807b63a385..0f179f355e3 100644 --- a/src/emc/motion/homing.c +++ b/src/emc/motion/homing.c @@ -1603,9 +1603,13 @@ static int base_1joint_state_machine(int joint_num) break; case HOME_ABORT: + /* stop every joint; joints that finished homing stay homed, + the others were unhomed when the command started */ for(int i = 0; i < all_joints; i++) { + if (H[i].homing) { + H[i].homed = 0; + } H[i].homing = 0; - H[i].homed = 0; H[i].joint_in_sequence = 0; joints[i].free_tp.enable = 0; H[i].home_state = HOME_IDLE; diff --git a/tests/home-dist/test-ui.py b/tests/home-dist/test-ui.py index 977f66fb5bd..5796423ef1c 100755 --- a/tests/home-dist/test-ui.py +++ b/tests/home-dist/test-ui.py @@ -55,9 +55,10 @@ def pos(j): return hal.get_value("joint.%d.motor-pos-cmd" % j) -def home(joint, label, expect): +def home(joint, label, expect, keep=()): # Home 'joint', wait for the homing to end, check that the expected - # message came and that the machine is still on and unhomed. + # message came, that the machine is still on, and that only the + # joints in 'keep' are homed. start = [pos(j) for j in range(3)] errors() c.teleop_enable(0) @@ -95,8 +96,9 @@ def home(joint, label, expect): sys.stdout.flush() if not any(expect in m for m in msgs): fail("%s: no error containing '%s'" % (label, expect)) - if any(s.homed[:3]): - fail("%s: a joint reports homed" % label) + for j in range(3): + if s.homed[j] != (j in keep): + fail("%s: joint %d homed=%d" % (label, j, s.homed[j])) if s.task_state != linuxcnc.STATE_ON: fail("%s: machine is no longer on" % label) return start, farthest, end @@ -172,6 +174,26 @@ def check_moved(label, j, start, farthest, dist): else: print("%-28s homed" % "working switch") +# A failed home of the pair stops it but leaves joint 0 homed: an abort +# unhomes only the joints that had not finished homing. +start, farthest, end = home(1, "pair fails, joint 0 homed", "did not clear", keep=(0,)) + +# Same in a Home All: joint 0 homes first and stays homed when the pair +# fails after it. +c.teleop_enable(0) +c.wait_complete() +c.home(-1) +c.wait_complete() +if not wait_for(lambda: any(j["homing"] for j in s.joint[1:3]), 20.0): + fail("home all: the pair did not start homing") +if not wait_for(lambda: not any(j["homing"] for j in s.joint[:3]), 20.0): + fail("home all: homing did not end") +elif not s.homed[0] or s.homed[1] or s.homed[2]: + fail("home all, pair fails: homed=%d,%d,%d, expected 1,0,0" % tuple(s.homed[:3])) +else: + print("%-28s joint 0 still homed" % "home all, pair fails") +errors() + c.state(linuxcnc.STATE_ESTOP) c.wait_complete()