Get the value of a HAL component
- elisa
- Offline
- Senior Member
Less
More
- Posts: 58
- Thank you received: 5
08 Apr 2021 13:29 #205321
by elisa
Get the value of a HAL component was created 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!
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.
- MaHa
- Offline
- Platinum Member
Less
More
- Posts: 405
- Thank you received: 163
08 Apr 2021 16:21 #205333
by MaHa
Replied by MaHa on topic Get the value of a HAL component
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.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23178
- Thank you received: 4860
08 Apr 2021 16:45 #205335
by andypugh
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.
Replied by andypugh on topic Get the value of a HAL component
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.
- elisa
- Offline
- Senior Member
Less
More
- Posts: 58
- Thank you received: 5
08 Apr 2021 21:11 #205366
by elisa
Replied by elisa on topic Get the value of a HAL component
I forgot to add "import linuxcnc".
Now It works, thank you ALL!
Now It works, thank you ALL!
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7778
- Thank you received: 2075
08 Apr 2021 22:58 #205380
by cmorley
Replied by cmorley on topic Get the value of a HAL component
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.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7778
- Thank you received: 2075
08 Apr 2021 23:01 #205381
by cmorley
Replied by cmorley on topic Get the value of a HAL component
It's not required in python 2
Please Log in or Create an account to join the conversation.
Time to create page: 0.056 seconds