Get current state of LinuxCNC trough HAL/Python

More
09 Aug 2015 01:08 #61230 by minitreintje
Hi everyone,

I need to check the current state of LinuxCNC trough a HAL pin which will trigger a Python script. This is necessary since I need to execute a command before LinuxCNC exits.

Can somebody help me with that? I don't know how I can check trough HAL if the user close LinuxCNC.

Regards,
Dylan

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

More
09 Aug 2015 02:42 #61233 by cmorley
What state of linuxcnc are you interested in?
How will you launch the script?
A python program can poll alot of info from linuxcnc.
www.linuxcnc.org/docs/2.6/html/common/python-interface.html

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

More
09 Aug 2015 06:55 #61235 by phillc54

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

More
09 Aug 2015 14:04 #61236 by minitreintje
@phillc54
I tried to use the HAL shutdown file but the command doesn't come trough.
LinuxCNC communicates with an Arduino (serial) trough Python, in the shutdown HAL file I put a parameter. The Python script reads the parameter each time.
However, I think the Python script is closed first before the LinuxCNC executes the shutdown HAL file. I tried to make a second Python script which will be called only when LinuxCNC shutdown but that doesn't work either.

@cmorley
I need to know when a user closes LinuxCNC so that I can execute a command to the Arduino (serial).

Dylan

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

More
10 Aug 2015 01:37 #61248 by cmorley
You could use gladevcp with a python handler file - I believe the manual on gladeVCP talks about catching linuxcnc closing.

You could use a python 'user HAL component' to do nothing but wait for an exception (HAL closing).
The exception code could do what you want.

Hope that helps

Chris M

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

More
10 Aug 2015 02:11 #61252 by minitreintje
Then I need to convert my PyVCP to GladeVCP.
I read somewhere I can add a keyboard hotkey to a GladeVCP button also that's the second thing I was looking for :)

Dylan

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

More
10 Aug 2015 20:45 #61277 by andypugh
I think the way to do this might be to use a shutdown/hal in the INI which calls your Python script.

You seem to say that you have tried this, but didn't say what syntax you used.

You probably need the shutdown.hal file to say
loadusr -W yourfile.py
Then the HAL file should wait for the python file to report finished before continuing.

It is likely that the Python script needs to create a hal component name for itself and signal ready() to handshake properly.
www.linuxcnc.org/docs/html/hal/halmodule.html

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

More
11 Aug 2015 23:20 #61299 by minitreintje
I tried that but the Arduino just does nothing.
I also tried with a HAL pin that waits until it's activated by shutdown.hal by:
setp arduino.linuxcnc-shutdown 1

which also does nothing.

Dylan

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

More
11 Aug 2015 23:28 #61300 by andypugh
Try "show pin" in the shutdown hal, and then start LinuxCNC from the command line.
That should indicate whether the HAL file is being executed or not.

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

More
26 Aug 2015 14:23 #61801 by minitreintje
Sorry I was on vacation, I will try it today and let you know.

Dylan

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

Time to create page: 0.117 seconds
Powered by Kunena Forum