gmoccapy pins
- Moutomation
- Offline
- Premium Member
Less
More
- Posts: 135
- Thank you received: 11
31 Jul 2024 11:48 #306505
by Moutomation
gmoccapy pins was created by Moutomation
Please Log in or Create an account to join the conversation.
- Aciera
- Away
- Administrator
Less
More
- Posts: 3923
- Thank you received: 1684
31 Jul 2024 11:55 #306508
by Aciera
Replied by Aciera on topic gmoccapy pins
for estop-activate use 'halui.estop.activate'
for estop-reset use 'halui.estop.reset'
for machine-on use 'halui.machine.on'
for machine-off use 'halui.machine.off
for home-button use 'halui.home-all '
for program-start use 'halui.program.run'
Gcode refresh I'm not sure.
linuxcnc.org/docs/html/man/man1/halui.1.html
for estop-reset use 'halui.estop.reset'
for machine-on use 'halui.machine.on'
for machine-off use 'halui.machine.off
for home-button use 'halui.home-all '
for program-start use 'halui.program.run'
Gcode refresh I'm not sure.
linuxcnc.org/docs/html/man/man1/halui.1.html
Please Log in or Create an account to join the conversation.
- Moutomation
- Offline
- Premium Member
Less
More
- Posts: 135
- Thank you received: 11
31 Jul 2024 12:14 #306511
by Moutomation
Replied by Moutomation on topic gmoccapy pins
Thanks a lot
Can program refresh be controlled from the classic ladder?
Can program refresh be controlled from the classic ladder?
Please Log in or Create an account to join the conversation.
- newbynobi
- Offline
- Moderator
Less
More
- Posts: 2075
- Thank you received: 406
04 Aug 2024 12:13 - 04 Aug 2024 12:13 #306911
by newbynobi
Replied by newbynobi on topic gmoccapy pins
I do recommend not to use halui pins, but the hardware button pins to control that stuff.
See:
Right and Botton Button Hal Pin
See:
Right and Botton Button Hal Pin
Last edit: 04 Aug 2024 12:13 by newbynobi.
The following user(s) said Thank You: Aciera, Moutomation
Please Log in or Create an account to join the conversation.
- Moutomation
- Offline
- Premium Member
Less
More
- Posts: 135
- Thank you received: 11
04 Aug 2024 14:38 #306921
by Moutomation
Replied by Moutomation on topic gmoccapy pins
Instead of binding this key to a button, is there a way to refresh the g-code file every few seconds while the g-code is not executing? I want to automatically load the g-code file into linuxcnc continuously. The name of the g-code file is always the same and never changes.
Please Log in or Create an account to join the conversation.
- Aciera
- Away
- Administrator
Less
More
- Posts: 3923
- Thank you received: 1684
06 Aug 2024 09:32 - 07 Aug 2024 06:33 #307066
by Aciera
Replied by Aciera on topic gmoccapy pins
Try this:
Save the python code below as 'file-check.py' into a folder named 'python' in your machine config folder and mark as executable.
This user component will create a hal pin 'file-checked.file-changed' and output a pulse if the file is modified:#!/usr/bin/env python3
To load this on startup add this to the [HAL] section of your .ini file:
then add this line to your POSTGUI_HALFILE:
Save the python code below as 'file-check.py' into a folder named 'python' in your machine config folder and mark as executable.
This user component will create a hal pin 'file-checked.file-changed' and output a pulse if the file is modified:#!/usr/bin/env python3
#!/usr/bin/env python3
import os
import time
import hal
import linuxcnc
h = hal.component("file-check")
h.newpin("file-changed", hal.HAL_BIT, hal.HAL_OUT)
h.ready()
# create a connection to the status channel
s = linuxcnc.stat()
# this is the file being checked for updates (example looks for 'file.txt' in the config folder)
file_path = 'file.txt'
# length of output puls in milliseconds
pulse_length = 1000
last_modified = os.path.getmtime(file_path)
h['file-changed'] = False
try:
while 1:
s.poll()
# we don't want to reload when program is running
if s.task_mode == 2 and s.state == 1: # ie AUTO-mode and 'RCS_DONE'
current_modified = os.path.getmtime(file_path)
if current_modified != last_modified:
print("File has changed!")
h['file-changed'] = True
timer_start = round(time.time()*1000)
last_modified = current_modified
if h['file-changed'] and timer_start + pulse_length <= round(time.time()*1000):
h['file-changed'] = False
except KeyboardInterrupt:
raise SystemExit
To load this on startup add this to the [HAL] section of your .ini file:
HALCMD = loadusr -W ./python/file-check.py
then add this line to your POSTGUI_HALFILE:
net file-reload file-check.file-changed gmoccapy.h-button.button-1
Last edit: 07 Aug 2024 06:33 by Aciera. Reason: add lost hashbang in the code
The following user(s) said Thank You: Moutomation
Please Log in or Create an account to join the conversation.
- Moutomation
- Offline
- Premium Member
Less
More
- Posts: 135
- Thank you received: 11
06 Aug 2024 18:10 #307113
by Moutomation
Replied by Moutomation on topic gmoccapy pins
You are great, thank you very much. I will try to do it tomorrow.
Please Log in or Create an account to join the conversation.
- Moutomation
- Offline
- Premium Member
Less
More
- Posts: 135
- Thank you received: 11
07 Aug 2024 06:26 #307144
by Moutomation
Replied by Moutomation on topic gmoccapy pins
Hello,
I think I'm making a mistake somewhere
The file.txt file is in the config folder, but I think it cannot find this file.
./python/file-check.py: 1: import: not found
./python/file-check.py: 2: import: not found
./python/file-check.py: 3: import: not found
./python/file-check.py: 4: import: not found
./python/file-check.py: 6: Syntax error: "(" unexpected
<commandline>:0: waitpid failed ./python/file-check.py file-check
<commandline>:0: ./python/file-check.py exited without becoming ready
I think I'm making a mistake somewhere
The file.txt file is in the config folder, but I think it cannot find this file.
./python/file-check.py: 1: import: not found
./python/file-check.py: 2: import: not found
./python/file-check.py: 3: import: not found
./python/file-check.py: 4: import: not found
./python/file-check.py: 6: Syntax error: "(" unexpected
<commandline>:0: waitpid failed ./python/file-check.py file-check
<commandline>:0: ./python/file-check.py exited without becoming ready
Please Log in or Create an account to join the conversation.
- Aciera
- Away
- Administrator
Less
More
- Posts: 3923
- Thank you received: 1684
07 Aug 2024 06:36 #307146
by Aciera
Replied by Aciera on topic gmoccapy pins
Seems likeI lost the hashbang in the first line of the python code in my last post.
I just fixed that, so copy/paste the fixtd python code above and try again.
I just fixed that, so copy/paste the fixtd python code above and try again.
The following user(s) said Thank You: Moutomation
Please Log in or Create an account to join the conversation.
- Aciera
- Away
- Administrator
Less
More
- Posts: 3923
- Thank you received: 1684
07 Aug 2024 06:51 #307148
by Aciera
Replied by Aciera on topic gmoccapy pins
Note, for the gcode to reload you need to switch to the 'AUTO' mode screen in gmoccapy.
The following user(s) said Thank You: Moutomation
Please Log in or Create an account to join the conversation.
Moderators: newbynobi, HansU
Time to create page: 0.189 seconds