Stop program from M-Code

More
25 Jun 2018 20:09 - 25 Jun 2018 20:10 #112859 by ciccio85
Hello,

I'm trying to setup a simple Mcode which asks to the user if some actions were performed before continuing with the program. If the actions were performed the user clicks on Continue, whereas if the actions were not performed the user clicks on STOP and the program stops. Here is the simple Mcode.
(sleep 1 && wmctrl -F -a "Probe" -b add,above) &
yad --title "Probe" --image=/home/ciccio/linuxcnc/configs/10060_4th/M-codes/qs.png --geometry="290x120" --text="<big>Hai fatto il probe? Hai posizionato il mandrino in un punto dove poter cambiare l'utensile?</big>" --button="STOP" --button="Continua"

case $? in
    0)sleep 2; halcmd setp halui.program.stop True
    ;;
esac
exit 0

The problems is that when I send the halcmd command I get an error: "can't do that emc_task_plan_run in auto mode with interpreter reading" and the program doesn't stop. Do you how to stop the program with halcmd?

Thank you

Francesco
Last edit: 25 Jun 2018 20:10 by ciccio85.

Please Log in or Create an account to join the conversation.

More
26 Jun 2018 20:23 #112907 by andypugh
Replied by andypugh on topic Stop program from M-Code
You could try halui.abort, though the docs say that they both do the same thing.

Please Log in or Create an account to join the conversation.

More
27 Jun 2018 08:02 #112918 by ciccio85
Replied by ciccio85 on topic Stop program from M-Code
Hello,

I already tried halui.abort but I get the same error.

Francesco

Please Log in or Create an account to join the conversation.

More
27 Jun 2018 09:03 #112921 by andypugh
Replied by andypugh on topic Stop program from M-Code
Do you get the same result if you connect a GUI (or physical) button to the stop / abort pins?

If you do then I think that means something is wrong.
Which version of LinuxCNC?

I just checked what Axis does
github.com/LinuxCNC/linuxcnc/blob/master...cripts/axis.py#L2287
And there seems to be no mode-switching there.

A workaround might be to switch your M-code to Python, though that definitely should not be necessary.

I will try to remember to check the behaviour in different versions and scenarios tonight. I feel that this might be a bug.

Please Log in or Create an account to join the conversation.

More
27 Jun 2018 09:07 #112923 by ciccio85
Replied by ciccio85 on topic Stop program from M-Code
Hello,

thank you for your reply. I will check tonight to connect a GUI button to see if it works. The version I use is the 2.7.13

Francesco

Please Log in or Create an account to join the conversation.

More
27 Jun 2018 11:26 #112926 by nkp
Replied by nkp on topic Stop program from M-Code
It works for me
(sleep 1 && wmctrl -F -a "Probe" -b add,above) &
yad --title "Probe"  --text="<big>Hai fatto il probe? Hai posizionato il mandrino in un punto dove poter cambiare l'utensile?</big>" --button="STOP" --button="Continua"

case $? in
    0)sleep 2; halcmd setp halui.program.stop False

    sleep 2; halcmd setp halui.program.stop True
    ;;
esac


exit 0
Attachments:

Please Log in or Create an account to join the conversation.

More
27 Jun 2018 11:31 #112927 by ciccio85
Replied by ciccio85 on topic Stop program from M-Code
OK,

so tonight I will try your modified script.

Thank you

Please Log in or Create an account to join the conversation.

More
27 Jun 2018 19:05 - 27 Jun 2018 20:52 #112936 by ciccio85
Replied by ciccio85 on topic Stop program from M-Code
Nothing, for me it does not work :(

I always have the same error, @andypugh using a normal GUI button works...very strange

Francesco
Last edit: 27 Jun 2018 20:52 by ciccio85. Reason: adding more informatio

Please Log in or Create an account to join the conversation.

More
27 Jun 2018 23:49 #112941 by andypugh
Replied by andypugh on topic Stop program from M-Code
I did some experiments.

I can get that error message by making the M101 file not executable.

The error message is unhelpful and wrong.

Please Log in or Create an account to join the conversation.

More
28 Jun 2018 06:22 #112971 by ciccio85
Replied by ciccio85 on topic Stop program from M-Code
My M-code was always executable. The permissions are: -rwxr-xr-x

Which version of linuxcnc did you use?

Please Log in or Create an account to join the conversation.

Time to create page: 0.074 seconds
Powered by Kunena Forum