Python commands lag time for remap

More
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
Last edit: 25 Dec 2024 21:23 by wrhammer. Reason: Formatting messed up

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

More
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?

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

More
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:
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.

More
30 Jan 2025 14:06 - 30 Jan 2025 14:06 #320148 by bevins
Replied by bevins on topic Python commands lag time for remap
self.execute("M64 P0")  ?
Last edit: 30 Jan 2025 14:06 by bevins.

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

More
21 Mar 2025 01:58 #324394 by wrhammer
Replied by wrhammer on topic Python commands lag time for remap
Self.execute was it! Finally getting back to the python testing. I pretty much got the rest of the machine up and going and it makes more sense to use the python M6 remap for a more automated experience with all the different tools on the Biesse. By the way thanks so much for posting your Biesse upgrade bevins! Mine is up on github also and plan to do a post covering my project. Been a learning experience!

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

Time to create page: 0.057 seconds
Powered by Kunena Forum