Get current state of LinuxCNC trough HAL/Python
- minitreintje
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
09 Aug 2015 01:08 #61230
by minitreintje
Get current state of LinuxCNC trough HAL/Python was created 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
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.
09 Aug 2015 02:42 #61233
by cmorley
Replied by cmorley on topic Get current state of LinuxCNC trough HAL/Python
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
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.
09 Aug 2015 06:55 #61235
by phillc54
Replied by phillc54 on topic Get current state of LinuxCNC trough HAL/Python
SHUTDOWN in the HAL section may help.
<www.linuxcnc.org/docs/html/config/ini_co...id_sub_hal_section_a>
<www.linuxcnc.org/docs/html/config/ini_co...id_sub_hal_section_a>
Please Log in or Create an account to join the conversation.
- minitreintje
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
09 Aug 2015 14:04 #61236
by minitreintje
Replied by minitreintje on topic Get current state of LinuxCNC trough HAL/Python
@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
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.
10 Aug 2015 01:37 #61248
by cmorley
Replied by cmorley on topic Get current state of LinuxCNC trough HAL/Python
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
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.
- minitreintje
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
10 Aug 2015 02:11 #61252
by minitreintje
Replied by minitreintje on topic Get current state of LinuxCNC trough HAL/Python
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
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.
10 Aug 2015 20:45 #61277
by andypugh
Replied by andypugh on topic Get current state of LinuxCNC trough HAL/Python
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 sayThen 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
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
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.
- minitreintje
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
11 Aug 2015 23:20 #61299
by minitreintje
Replied by minitreintje on topic Get current state of LinuxCNC trough HAL/Python
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:
which also does nothing.
Dylan
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.
11 Aug 2015 23:28 #61300
by andypugh
Replied by andypugh on topic Get current state of LinuxCNC trough HAL/Python
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.
That should indicate whether the HAL file is being executed or not.
Please Log in or Create an account to join the conversation.
- minitreintje
- Offline
- New Member
Less
More
- Posts: 12
- Thank you received: 0
26 Aug 2015 14:23 #61801
by minitreintje
Replied by minitreintje on topic Get current state of LinuxCNC trough HAL/Python
Sorry I was on vacation, I will try it today and let you know.
Dylan
Dylan
Please Log in or Create an account to join the conversation.
Time to create page: 0.117 seconds