Issue calling cutom o-word from Python M6 remap script

More
27 Dec 2023 17:38 #289187 by tom_no
Hi,

As part of configuring my ATC, I'm trying to call a custom m-code (m301.ngc) from remap.py M6 remap-script.
Is this at all possible?

My custom M-codes all work from MDI and is intended to handle all machine movements related to the ATC. M300 to stop and reset spindles M301 to pick tool from pockets, M302 to place tool in pocket.

remap.py runs as intended in "dry mode", but does not run the m-code.

Following lines in remap.py:

print("Executing command M301 P%d" % selectedpocket)
if dry_run == False:
self.execute("M301 P%d" % selectedpocket)

gives this output in terminal window:

Executing command M301 P3
is_callable(oword.m301) = FALSE
is_callable(oword.m300) = FALSE
remap_finished: got -8 - not in cblock.remappings!


Struggling to troubleshoot this issue, so any an all input will be greatly appreciated!

Kind regards
TomE.

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

More
28 Dec 2023 12:04 #289241 by tom_no
After re-reading bevins' lesson learned on Python remap I suspect my problem to be related to the interpreter not being able to run several scripts in a row. IE: TopLevel.py -> remap.py -> M30x.NGC is "a bridge too far".

Bit the bullit and moved the M30x code into remap.py as functions. Seems to work, and I'm moving forward. :-)

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

More
07 Jan 2024 22:41 #290153 by andypugh
I think that the problem is that you can't "MDI"G0code commands inside a Python remap (as the system is in "Auto" mode. Basically the interpreter is in-use.

The answer is generally to use the Python interface or canonical function calls.
The latter are not particularly well documented.
But this search on github will show some examples:
github.com/search?q=repo%3ALinuxCNC%2Fli...n&type=code&l=Python

for example emcconon.STRAIGHT_FEED and emccoanon.STRAIGHT_TRAVERSE

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

More
15 Jan 2024 20:14 #290790 by tom_no
Thanks Andy! I'll try converting to canoncical function calls where I'm stuck. As per now the M6 script is running as expected, only need to add check that all tool pockets are retracted before shutting ATC cover to avoid expensive collissions.

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

Time to create page: 0.074 seconds
Powered by Kunena Forum