Python interface states of the home switches?
16 Mar 2018 15:50 #107432
by bladekel
Python interface states of the home switches? was created by bladekel
Hello to all,
I'm creating a new GUI and I need to get the state of a home switch to light on the hal_led.
I can get the state of estop like;
self.led_estop.set_active(not self.s.estop)
Is there any way to get the home switches states like estop ?
I'm creating a new GUI and I need to get the state of a home switch to light on the hal_led.
I can get the state of estop like;
self.led_estop.set_active(not self.s.estop)
Is there any way to get the home switches states like estop ?
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
16 Mar 2018 16:36 - 16 Mar 2018 16:44 #107437
by Todd Zuercher
Replied by Todd Zuercher on topic Python interface states of the home switches?
Not sure about the state of home inputs the same way as you are looking at e-stop. But it is trivial to get the state of a hal pin and since your home switches are or are connected to hal pins there you go.
linuxcnc.org/docs/html/hal/halmodule.htm..._pins_and_parameters
linuxcnc.org/docs/html/hal/halmodule.htm..._pins_and_parameters
Last edit: 16 Mar 2018 16:44 by Todd Zuercher.
Please Log in or Create an account to join the conversation.
16 Mar 2018 17:28 #107440
by cmorley
Replied by cmorley on topic Python interface states of the home switches?
No at the moment there is no way to directly read a HAL pin with python.
You can make a python component that you can connect to a HAL signal with:
linuxcnc.org/docs/2.7/html/hal/halmodule.html
then you can read the signal.
I do have code to add this capability - hopefully it will be added to master.
Chris M
You can make a python component that you can connect to a HAL signal with:
linuxcnc.org/docs/2.7/html/hal/halmodule.html
then you can read the signal.
I do have code to add this capability - hopefully it will be added to master.
Chris M
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
16 Mar 2018 17:44 #107441
by Todd Zuercher
Replied by Todd Zuercher on topic Python interface states of the home switches?
I guess I don't understand. How is it am I making, monitoring and controlling hal pins with the python file for my Gladevcp then?
Please Log in or Create an account to join the conversation.
16 Mar 2018 21:16 #107447
by cmorley
Replied by cmorley on topic Python interface states of the home switches?
I assume you are making a python component with it's own pins and connecting those pins to other pins you are interested in, so as to read or write.
That's different from just reading a pin directly (like using halmeter) without connecting to it.
Chris M
That's different from just reading a pin directly (like using halmeter) without connecting to it.
Chris M
Please Log in or Create an account to join the conversation.
16 Mar 2018 21:31 #107449
by cmorley
Replied by cmorley on topic Python interface states of the home switches?
An example of the new way would be:
Chris M
import hal
actual_spindle_rpm = hal.get_value('motion.spindle-speed-in') * 60
Chris M
Please Log in or Create an account to join the conversation.
17 Mar 2018 05:30 #107457
by bladekel
Hi Chris.
I get "AttributeError: 'module' object has no attribute 'get_value'" error by this method....
Replied by bladekel on topic Python interface states of the home switches?
An example of the new way would be:
import hal actual_spindle_rpm = hal.get_value('motion.spindle-speed-in') * 60
Chris M
Hi Chris.
I get "AttributeError: 'module' object has no attribute 'get_value'" error by this method....
Please Log in or Create an account to join the conversation.
17 Mar 2018 12:23 #107465
by cmorley
Replied by cmorley on topic Python interface states of the home switches?
Sorry i wasn't clear - I haven't pushed the code to master yet.
If you are using 2.7.x then this will never work.
If you are using master I could cherry pick the code and push to master in a day or so.
Chris M
If you are using 2.7.x then this will never work.
If you are using master I could cherry pick the code and push to master in a day or so.
Chris M
Please Log in or Create an account to join the conversation.
17 Mar 2018 13:25 #107466
by bladekel
Then what must I do ?
Please help me
Replied by bladekel on topic Python interface states of the home switches?
Unfortunately I'm using 2.7.x ....Sorry i wasn't clear - I haven't pushed the code to master yet.
If you are using 2.7.x then this will never work.
If you are using master I could cherry pick the code and push to master in a day or so.
Chris M
Then what must I do ?
Please help me
Please Log in or Create an account to join the conversation.
17 Mar 2018 18:42 #107473
by cmorley
Replied by cmorley on topic Python interface states of the home switches?
Then the practical thing to do is to (as Todd mentioned) create HAL pins for your screen and connect them to the signals/pins you are interested in.
Chris M
Chris M
Please Log in or Create an account to join the conversation.
Time to create page: 0.091 seconds