Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/python/common/hal_glib.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,9 @@ def update(self):
state_new = self.old['state']
if state_new != state_old:

# set machine estop/clear
if state_old == linuxcnc.STATE_ESTOP and state_new == linuxcnc.STATE_ESTOP_RESET:
# set machine estop/clear; a reset and machine on between two
# polls go from ESTOP straight to ON and still clear the estop
if state_old == linuxcnc.STATE_ESTOP:
self.emit('state-estop-reset')
self.emit('interp-idle')
elif state_new == linuxcnc.STATE_ESTOP:
Expand Down
18 changes: 15 additions & 3 deletions scripts/linuxcnc.in
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,21 @@ function Cleanup() {
# Unused variable 'i', just a counter
# shellcheck disable=SC2034
for i in $(seq 10); do
# (the one component is the halcmd itself; a thread is listed as
# a __<name> pseudo component, which stays until realtime stops)
if [ "$($HALCMD list comp | tr -s ' ' '\n' | grep -c -v -e '^__' -e '^$')" = 1 ]; then break; fi
# Wait only for components that can still leave: a thread is
# listed as a __<name> pseudo component, which stays until
# realtime stops, and a user component whose process is gone
# (a GUI that exited without hal_exit) never leaves. The halcmd
# that listed them has exited by the time its pid is checked.
COMPS=$($HALCMD -s show comp)
BUSY=0
while read -r _ TYPE NAME PID _; do
case "$TYPE:$NAME" in
RT:__*) ;;
RT:*) BUSY=1 ;;
User:*) if "$KILL" -0 "$PID" 2>/dev/null; then BUSY=1; fi ;;
esac
done <<< "$COMPS"
if [ "$BUSY" = 0 ]; then break; fi
sleep .2
done

Expand Down
21 changes: 14 additions & 7 deletions src/emc/usr_intf/gmoccapy/gmoccapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3100,16 +3100,24 @@ def on_hal_status_tool_in_spindle_changed(self, object, new_tool_no):
self.prefs.putpref("tool_in_spindle", new_tool_no, int)
self._update_toolinfo(new_tool_no)

# Show a state change on a toggle button without its toggled handler,
# which would send the state again: when this runs late, that is an old
# state, and an ESTOP_RESET to a machine already on aborts its motion.
def _show_toggle(self, widget, active):
handler = icon_theme_helper.find_handler_id_by_signal(widget, "toggled")
with widget.handler_block(handler):
widget.set_active(active)

def on_hal_status_state_estop(self, widget=None):
self.widgets.tbtn_estop.set_active(True)
self._show_toggle(self.widgets.tbtn_estop, True)
self.widgets.tbtn_estop.set_image(self.widgets.img_emergency)
self.widgets.tbtn_on.set_image(self.widgets.img_machine_off)
self.widgets.tbtn_on.set_sensitive(False)
self.widgets.tbtn_on.set_active(False)
self._show_toggle(self.widgets.tbtn_on, False)
self.command.mode(linuxcnc.MODE_MANUAL)

def on_hal_status_state_estop_reset(self, widget=None):
self.widgets.tbtn_estop.set_active(False)
self._show_toggle(self.widgets.tbtn_estop, False)
self.widgets.tbtn_estop.set_image(self.widgets.img_emergency_off)
self.widgets.tbtn_on.set_image(self.widgets.img_machine_off)
self.widgets.tbtn_on.set_sensitive(True)
Expand All @@ -3132,8 +3140,7 @@ def on_hal_status_state_off(self, widget):
"btn_tool_touchoff_x", "btn_tool_touchoff_z"
]
self._sensitize_widgets(widgetlist, False)
if self.widgets.tbtn_on.get_active():
self.widgets.tbtn_on.set_active(False)
self._show_toggle(self.widgets.tbtn_on, False)
self.widgets.tbtn_on.set_image(self.widgets.img_machine_off)
self.widgets.btn_exit.set_sensitive(True)
self.widgets.ntb_main.set_current_page(0)
Expand All @@ -3148,8 +3155,8 @@ def on_hal_status_state_on(self, widget):
"btn_spindle_100", "spc_rapid", "spc_spindle"
]
self._sensitize_widgets(widgetlist, True)
if not self.widgets.tbtn_on.get_active():
self.widgets.tbtn_on.set_active(True)
self._show_toggle(self.widgets.tbtn_on, True)
self._update_widgets(True)
self.widgets.tbtn_on.set_image(self.widgets.img_machine_on)
self.widgets.btn_exit.set_sensitive(False)
if self.widgets.ntb_main.get_current_page() != 0:
Expand Down
5 changes: 5 additions & 0 deletions src/hal/user_comps/gladevcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ def main():
LOG.debug("Register callback '%s' for SIGINT and SIGTERM" %(signal_func))
signal.signal(signal.SIGTERM, handlers[signal_func])
signal.signal(signal.SIGINT, handlers[signal_func])
else:
# halcmd unload sends SIGTERM. The KeyboardInterrupt hal makes of
# it is lost when it lands in a GLib callback (the status polls),
# so quit from the main loop instead.
GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGTERM, Gtk.main_quit)

try:
Gtk.main()
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-smoke/_lib/checkresult.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Pass if the driver printed UI_SMOKE_OK and did not print UI_SMOKE_FAIL.
# The driver only emits UI_SMOKE_OK after a successful NML round-trip
# (linuxcnc task ready and stat.poll() still alive after settle), so
# (linuxcnc task ready and stat.poll() still alive once the GUI is up), so
# this is sufficient evidence that the GUI booted. We do not grep for
# generic crash markers like "Segmentation fault" or "Traceback":
# linuxcnc's own scripts/linuxcnc Cleanup may emit shutdown-side
Expand Down
Loading
Loading