Get the value of a HAL component

More
08 Apr 2021 13:29 #205321 by elisa
Hi to all,

I have a big question. How can I get the value of a HAL component from a Python script?
In the documentation I found the command "hal.get_value()" but it doesn't seem to work ..

Any suggestions?

Please write soon!

Please Log in or Create an account to join the conversation.

More
08 Apr 2021 16:21 #205333 by MaHa
This reading the actual value, s2n2 is a signal
px=hal.get_value("s2n2")
The following user(s) said Thank You: elisa

Please Log in or Create an account to join the conversation.

More
08 Apr 2021 16:45 #205335 by andypugh

but it doesn't seem to work


How does it not work?

You may need "import hal" and you may also need "import linuxcnc"

You can set up your Python script to create its own HAL pins, then use those as variables in your script without having to poll them.
The following user(s) said Thank You: elisa

Please Log in or Create an account to join the conversation.

More
08 Apr 2021 21:11 #205366 by elisa
I forgot to add "import linuxcnc".

Now It works, thank you ALL!

Please Log in or Create an account to join the conversation.

More
08 Apr 2021 22:58 #205380 by cmorley
hmm I wouldn't of expected to need to import linuxcnc for HAL pins to work...

Please Log in or Create an account to join the conversation.

More
08 Apr 2021 23:01 #205381 by cmorley
It's not required in python 2

Please Log in or Create an account to join the conversation.

Time to create page: 0.454 seconds
Powered by Kunena Forum