- Posts: 25
- Thank you received: 0
Set HAL-Pin Values by Python Script
I try to Set a Hal-Pin Value in a Method of a Python script, associated with Glade VCP.
Example Python Script:
What Method or Syntax could i use?
Please help me,
Thomas Kümmel
Please Log in to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
- Posts: 4739
- Thank you received: 2
Just curious why you need the hal pin out? Most of the hal widgets for GladeVCPs create their own hal pins automatically so you don't need to put them in the python script.
Please Log in to join the conversation.
My Python Skills aren`t very well too.
My main calculations i write in a "HAL Component" in C.
but it is laborious to connect every Button, LED, ... in The PostGUI, the Hal File and define in the component File
But unfortunatualy i haven`t found a way to access Glade and the Hal-Layer with a C-Script direct.
For easy HALButtons, glade create automatic HAL-Pins,
But for eg. TreeView and ListStore Objects, they don`t.
But how to get These Values ( Bit and Int) to my C-HAL Component?
Please Log in to join the conversation.
use SOME_PIN_REFERENCE.get() for get the value of a pin
Chris M
Please Log in to join the conversation.
It's possible to do something like what you want- there are some recently documented commands for the python component.Thom wrote: Thank you Todd for fast reply,
But unfortunatualy i haven`t found a way to access Glade and the Hal-Layer with a C-Script direct.
linuxcnc.org/docs/2.7/html/hal/halmodule...l#_helpful_functions
hal.connect("pinname","signal_name")
hal.new_sig("signalname",hal.HAL_BIT)
but you would need a pretty good reason to use it - it's not as flexible as using HAL files.
Thom wrote: For easy HALButtons, glade create automatic HAL-Pins,
But for eg. TreeView and ListStore Objects, they don`t.
But how to get These Values ( Bit and Int) to my C-HAL Component?
HALbuttons etc are specifically made general widgets for interfacing HAL to pyGTK.
there are a lot of HAL widgets, I haven't heard anyone wishing for more widgets in a while.
If there are lacking HAL widgets, one would need to build them. We are always interested in new code.
Treeview and liststore are used inside of a parent widget, so I'm not sure how one could add HAL pins to them in a general way.
Combobox widgets use liststores IIRC and I believe there is a HALified combobox - this would be the usual way.
Hard to elaborate more without know what you are trying to do
Chris M
Please Log in to join the conversation.
Thats the Key:
Here is my way to get the selected row of a Treeview in a HAL-Pin:
The Treeview and the Liststore are created in Glade.
The vlaues of the Liststore are also preset in Glade.
Please Log in to join the conversation.
hal.connect("pinname","signal_name")
hal.new_sig("signalname",hal.HAL_BIT) , ...
but if i write this in Python or the following in the HAL File
net signalname pinname
does not make a difference
Please Log in to join the conversation.
Thom wrote: I`ve heard about the funktions:
hal.connect("pinname","signal_name")
hal.new_sig("signalname",hal.HAL_BIT) , ...
but if i write this in Python or the following in the HAL File
net signalname pinname
does not make a difference
As I said one needs a good reason to use this - for instance Pncconf used it to automatically build a test screen on objects that could be different each time (in fact that is what they were added for)
I also wanted to point out the get() and set() functions work because you used hal_glib to make the pins.
if you make pins like in the manual here:
linuxcnc.org/docs/2.7/html/hal/halmodule.html
the get() and set() functions are not available.
Chris M
Chriis
Please Log in to join the conversation.
