Add HAL Pins to GUI
- JT
-
Topic Author
- Away
- Administrator
-
Less
More
- Posts: 1121
- Thank you received: 615
06 Feb 2024 07:26 - 06 Feb 2024 07:29 #292645
by JT
Add HAL Pins to GUI was created by JT
I have a simple GUI and I'm trying to add a HAL pin.
But after running this and opening up showhal I don't see the pin... what am I missing?
I've grepped all the linuxcnc code and searched the forum for a clue but come up empty handed...
JT
def setup_hal(parent):
c = hal.component("buttons")
c.newpin('out', hal.HAL_BIT, hal.HAL_OUT)
c.ready()But after running this and opening up showhal I don't see the pin... what am I missing?
I've grepped all the linuxcnc code and searched the forum for a clue but come up empty handed...
JT
Last edit: 06 Feb 2024 07:29 by JT.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7368
- Thank you received: 2181
06 Feb 2024 07:37 #292646
by cmorley
Replied by cmorley on topic Add HAL Pins to GUI
Are you sure the function is being called?
Please Log in or Create an account to join the conversation.
- JT
-
Topic Author
- Away
- Administrator
-
Less
More
- Posts: 1121
- Thank you received: 615
06 Feb 2024 07:43 #292647
by JT
Replied by JT on topic Add HAL Pins to GUI
Thanks for replying Chris.
If I add a print function like this:it prints to the terminal.
JT
If I add a print function like this:
def setup_hal(parent):
print('here')
c = hal.component("buttons")
c.newpin('out', hal.HAL_BIT, hal.HAL_OUT)
c.ready()JT
Please Log in or Create an account to join the conversation.
- JT
-
Topic Author
- Away
- Administrator
-
Less
More
- Posts: 1121
- Thank you received: 615
06 Feb 2024 07:43 #292648
by JT
Replied by JT on topic Add HAL Pins to GUI
Attachments:
Please Log in or Create an account to join the conversation.
- JT
-
Topic Author
- Away
- Administrator
-
Less
More
- Posts: 1121
- Thank you received: 615
06 Feb 2024 07:45 #292649
by JT
Replied by JT on topic Add HAL Pins to GUI
Hmm it shows up even if I don't run that function so I assume it's part of Lcnc.
JT
JT
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7368
- Thank you received: 2181
06 Feb 2024 07:54 - 06 Feb 2024 07:55 #292654
by cmorley
Replied by cmorley on topic Add HAL Pins to GUI
I wonder if it's because c is a local variable and is garbage collected. try:
c= None
def setup_hal(parent):
print('here')
global c
c = hal.component("buttons")
c.newpin('out', hal.HAL_BIT, hal.HAL_OUT)
c.ready()
Last edit: 06 Feb 2024 07:55 by cmorley.
The following user(s) said Thank You: JT
Please Log in or Create an account to join the conversation.
- JT
-
Topic Author
- Away
- Administrator
-
Less
More
- Posts: 1121
- Thank you received: 615
06 Feb 2024 07:55 #292655
by JT
Replied by JT on topic Add HAL Pins to GUI
If I add a test to see if the component exists it returns True
JT
def setup_hal(parent):
c = hal.component("buttons")
c.newpin('out', hal.HAL_BIT, hal.HAL_OUT)
c.ready()
print(hal.component_exists("buttons"))JT
Please Log in or Create an account to join the conversation.
- JT
-
Topic Author
- Away
- Administrator
-
Less
More
- Posts: 1121
- Thank you received: 615
06 Feb 2024 07:58 #292657
by JT
Replied by JT on topic Add HAL Pins to GUI
Chris, thanks so much. You nailed it, c was garbage collected!
JT
JT
The following user(s) said Thank You: cmorley
Please Log in or Create an account to join the conversation.
Time to create page: 0.161 seconds