Python Component - $PATH
Attachments:
Please Log in or Create an account to join the conversation.
But the file you posted line 2 is different:halcmd: Traceback (most recent call last):
File "/home/zdenek/linuxcnc/linuxcnc-2.8.4/bin/passthrough", line 2, in <module>
h = hal.component("passthrough")
NameError: name 'hal' is not defined
1 #!/usr/bin/env python3
2 import hal, time
3 h = hal.component("passthrough")
4 h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
5 h.newpin("out", hal.HAL_FLOAT, hal.HAL_OUT)
6 h.ready()
7 try:
8 while 1:
9 time.sleep(1)
10 h['out'] = h['in']
11 except KeyboardInterrupt:
12 raise SystemExit
You might not be running the file you think you are.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Because, this is not halcompiled file.I will find the halcompiled file and send it tonight.But the file you posted line 2 is different:
Please Log in or Create an account to join the conversation.
#!/usr/bin/python3.7
h = hal.component("passthrough")
h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("out", hal.HAL_FLOAT, hal.HAL_OUT)
h.ready()
try:
while 1:
time.sleep(1)
h['out'] = h['in']
except KeyboardInterrupt:
raise SystemExit
halcompile stole "import hal, time".
Why?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Try adding a blank line immediately before the import line in passthrough.py
It helped. It works. Thank you.
/home/zdenek/linuxcnc/linuxcnc-2.9/passthrough.py
#!/usr/bin/env python3
import hal, time
h = hal.component("passthrough")
h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("out", hal.HAL_FLOAT, hal.HAL_OUT)
h.ready()
try:
while 1:
time.sleep(1)
h['out'] = h['in']
except KeyboardInterrupt:
raise SystemExit
/home/zdenek/linuxcnc/linuxcnc-2.9/bin/passthrough
#!/usr/bin/python3.7
import hal, time
h = hal.component("passthrough")
h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("out", hal.HAL_FLOAT, hal.HAL_OUT)
h.ready()
try:
while 1:
time.sleep(1)
h['out'] = h['in']
except KeyboardInterrupt:
raise SystemExit
Is this a bug?
This example is here:
linuxcnc.org/docs/2.9/html/hal/halmodule..._basic_usage_example
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.