Python commands lag time for remap
- wrhammer
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 0
25 Dec 2024 21:20 - 25 Dec 2024 21:23 #317374
by wrhammer
Python commands lag time for remap was created by wrhammer
Hello,
I am converting a Biesse Rover 13s over to LinxCNC and am testing the remap functions with Python and the commands take about 5 seconds to process each one. It's nearly instantaneous from MDI and I don't see any errors in the terminal output when the python command runs. It also works just fine when I reference a straight ,ngc file with REMAP=M201 modalgroup=10 ngc=m201.
Any ideas as to why Python is so slow? I can use the direct ngc remaps but would like to experiment with python also.
Terminal output when running Python
is_callable(oword.remap_m201) = FALSE
Executing remap_m201: Loading m201...
Wait 10 seconds
m201 executed successfully.
task: main loop took 65.045437 seconds
toplevel.py
import sys
import remap
My INI file
[RS274NGC]
PARAMETER_FILE = linuxcnc.var
USER_M_PATH = ngc
SUBROUTINE_PATH = ngc
#RS274NGC_STARTUP_CODE = G21 G40 G90 G94 G97 G64 P0.025
#REMAP=M201 modalgroup=10 ngc=m201
REMAP=M201 modalgroup=10 python=remap_m201
#ENABLE_EMBEDDED_PYTHON=1
DEBUG = 5
[PYTHON]
TOPLEVEL=/home/wrhammer/linuxcnc/configs/Rover13s/python/toplevel.py
#PATH_PREPEND=/home/wrhammer/linuxcnc/configs/Rover13s
PATH_APPEND=/home/wrhammer/linuxcnc/configs/Rover13s/python/
LOG_LEVEL=10
Python Test Scipt:
def remap_m201(prolog, params=None):
"""
Python-based remap for M201 to manually load and execute m201.ngc.
"""
print("Executing remap_m201: Loading m201...")
import linuxcnc
cmd = linuxcnc.command()
try:
cmd.mdi("M64 P0")
cmd.wait_complete()
cmd.mdi("M64 P1")
cmd.wait_complete()
cmd.mdi("M64 P2")
cmd.wait_complete()
print("Wait 10 seconds")
cmd.mdi("G4 P10")
cmd.wait_complete()
cmd.mdi("M65 P0")
cmd.wait_complete()
cmd.mdi("M65 P1")
cmd.wait_complete()
cmd.mdi("M65 P2")
print("m201 executed successfully.")
except Exception as e:
print(f"Error in remap_m201: {e}")
return
I am converting a Biesse Rover 13s over to LinxCNC and am testing the remap functions with Python and the commands take about 5 seconds to process each one. It's nearly instantaneous from MDI and I don't see any errors in the terminal output when the python command runs. It also works just fine when I reference a straight ,ngc file with REMAP=M201 modalgroup=10 ngc=m201.
Any ideas as to why Python is so slow? I can use the direct ngc remaps but would like to experiment with python also.
Terminal output when running Python
is_callable(oword.remap_m201) = FALSE
Executing remap_m201: Loading m201...
Wait 10 seconds
m201 executed successfully.
task: main loop took 65.045437 seconds
toplevel.py
import sys
import remap
My INI file
[RS274NGC]
PARAMETER_FILE = linuxcnc.var
USER_M_PATH = ngc
SUBROUTINE_PATH = ngc
#RS274NGC_STARTUP_CODE = G21 G40 G90 G94 G97 G64 P0.025
#REMAP=M201 modalgroup=10 ngc=m201
REMAP=M201 modalgroup=10 python=remap_m201
#ENABLE_EMBEDDED_PYTHON=1
DEBUG = 5
[PYTHON]
TOPLEVEL=/home/wrhammer/linuxcnc/configs/Rover13s/python/toplevel.py
#PATH_PREPEND=/home/wrhammer/linuxcnc/configs/Rover13s
PATH_APPEND=/home/wrhammer/linuxcnc/configs/Rover13s/python/
LOG_LEVEL=10
Python Test Scipt:
def remap_m201(prolog, params=None):
"""
Python-based remap for M201 to manually load and execute m201.ngc.
"""
print("Executing remap_m201: Loading m201...")
import linuxcnc
cmd = linuxcnc.command()
try:
cmd.mdi("M64 P0")
cmd.wait_complete()
cmd.mdi("M64 P1")
cmd.wait_complete()
cmd.mdi("M64 P2")
cmd.wait_complete()
print("Wait 10 seconds")
cmd.mdi("G4 P10")
cmd.wait_complete()
cmd.mdi("M65 P0")
cmd.wait_complete()
cmd.mdi("M65 P1")
cmd.wait_complete()
cmd.mdi("M65 P2")
print("m201 executed successfully.")
except Exception as e:
print(f"Error in remap_m201: {e}")
return
Last edit: 25 Dec 2024 21:23 by wrhammer. Reason: Formatting messed up
Please Log in or Create an account to join the conversation.
- cmorley
- Away
- Moderator
Less
More
- Posts: 7772
- Thank you received: 2059
26 Dec 2024 19:10 #317427
by cmorley
Replied by cmorley on topic Python commands lag time for remap
The default timeout for wait_complete() is 5 seconds.
Do you need wait_complete?
Do you need wait_complete?
Please Log in or Create an account to join the conversation.
- wrhammer
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 0
27 Dec 2024 01:28 #317449
by wrhammer
Replied by wrhammer on topic Python commands lag time for remap
I don't need wait_complete but was trying different things. With a simple M64 P0 it takes 5 seconds for it to command the pin. Feels like a config somewhere in the python plugin maybe?
remap.py:
remap.py:
def remap_m201(prolog, params=None):
print("Executing remap_m201: Loading m201...")
import linuxcnc
cmd = linuxcnc.command()
try:
cmd.mdi("M64 P0")
print("m201 executed successfully.")
except Exception as e:
print(f"Error in remap_m201: {e}")
return
is_callable(oword.remap_m201) = FALSE
Executing remap_m201: Loading m201...
m201 executed successfully.
task: main loop took 5.023382 seconds
Please Log in or Create an account to join the conversation.
Time to create page: 0.050 seconds