Add HAL Pins to GUI

More
2 years 8 months ago #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.


Code:
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

Please Log in to join the conversation.

More
2 years 8 months ago #292646 by cmorley
Replied by cmorley on topic Add HAL Pins to GUI
Are you sure the function is being called?

Please Log in to join the conversation.

More
2 years 8 months ago #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:
Code:
def setup_hal(parent): print('here') c = hal.component("buttons") c.newpin('out', hal.HAL_BIT, hal.HAL_OUT) c.ready()
it prints to the terminal.

JT

Please Log in to join the conversation.

More
2 years 8 months ago #292648 by JT
Replied by JT on topic Add HAL Pins to GUI
There is an odd component I think showing up in halshow.
 

Attachment not found



JT

Please Log in to join the conversation.

More
2 years 8 months ago #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

Please Log in to join the conversation.

More
2 years 8 months ago #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:
Code:
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()  

Please Log in to join the conversation.

More
2 years 8 months ago #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
Code:
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 to join the conversation.

More
2 years 8 months ago #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

Please Log in to join the conversation.

Time to create page: 0.091 seconds
Powered by Kunena Forum