Remap M code
- chen1234
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 58
- Thank you received: 2
16 Aug 2021 08:40 #217862
by chen1234
Remap M code was created by chen1234
When I remap M708, define my M code as required:
[RS274NGC]
REMAP = M708 modalgroup=10 argspec=ABC ngc=m708
And put m708 in:
SUBROUTINE_PATH = ../../linuxcnc/nc_files/gladevcp_lib
In the directory, but I tested my M code in linuxcnc MDI: M708 A123 B456 C789, linuxcnc cannot execute it and told me that M code>199.
How should I set this up?
Thanks in advance
[RS274NGC]
REMAP = M708 modalgroup=10 argspec=ABC ngc=m708
And put m708 in:
SUBROUTINE_PATH = ../../linuxcnc/nc_files/gladevcp_lib
In the directory, but I tested my M code in linuxcnc MDI: M708 A123 B456 C789, linuxcnc cannot execute it and told me that M code>199.
How should I set this up?
Thanks in advance
Please Log in or Create an account to join the conversation.
- chen1234
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 58
- Thank you received: 2
16 Aug 2021 08:55 #217863
by chen1234
Replied by chen1234 on topic Remap M code
My m708.ngc:
o<m708> sub
(debug,A word= #<A>)
(debug,B word= #<B>)
(debug,C word= #<C>)
o<m708> endsub
M2
My M708 code:
#!/bin/bash
#The value of the output parameter
echo "A=$1"
echo "B=$2"
echo "C=$3"
exit 0
o<m708> sub
(debug,A word= #<A>)
(debug,B word= #<B>)
(debug,C word= #<C>)
o<m708> endsub
M2
My M708 code:
#!/bin/bash
#The value of the output parameter
echo "A=$1"
echo "B=$2"
echo "C=$3"
exit 0
Please Log in or Create an account to join the conversation.
- rodw
- Offline
- Platinum Member
Less
More
- Posts: 10805
- Thank you received: 3559
16 Aug 2021 09:16 #217866
by rodw
Replied by rodw on topic Remap M code
User defined codes are M100 to M199
linuxcnc.org/docs/2.8/html/gcode/m-code.html#mcode:m100-m199
linuxcnc.org/docs/2.8/html/gcode/m-code.html#mcode:m100-m199
Please Log in or Create an account to join the conversation.
- chen1234
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 58
- Thank you received: 2
16 Aug 2021 10:12 #217870
by chen1234
Replied by chen1234 on topic Remap M code
Thanks for your reply, but M100-M199 only has two parameters P and Q; I need to recreate or remap an M code to realize the identification of the three parameters.
I am using linuxcnc.org/docs/2.8/html/remap/remap.h...xample_remapped_code and try it with M400, linuxcnc can output the values of p and q, but my remapped M708 cannot be executed.
I am using linuxcnc.org/docs/2.8/html/remap/remap.h...xample_remapped_code and try it with M400, linuxcnc can output the values of p and q, but my remapped M708 cannot be executed.
Please Log in or Create an account to join the conversation.
- chen1234
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 58
- Thank you received: 2
17 Aug 2021 02:30 #217943
by chen1234
Replied by chen1234 on topic Remap M code
I found my problem, my configuration file was wrong, now it's solved
Please Log in or Create an account to join the conversation.
- chen1234
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 58
- Thank you received: 2
17 Aug 2021 07:03 #217958
by chen1234
Replied by chen1234 on topic Remap M code
I succeeded in remapping an M code, but I cannot execute the shell script while executing the M code.I want to execute my script while executing the remapped M code. I need to pass parameters in the script, get this parameter?
My settings:
[RS274NGC]
SUBROUTINE_PATH = /home/zyz/linuxcnc/nc_files/gladevcp_lib
REMAP =M708 modalgroup=10 argspec=PQR ngc=mytest
My code:
mytest.ngc:
o<mytest> sub
(debug, P word=#<P>)
(debug, Q word=#<Q>)
(debug, R word=#<R>)
o<mytest> endsub
M2
After linuxcnc executes the M code, the output will be displayed in the lower right corner of the interface, but it is not displayed on the Ubuntu terminal.
M708:
#!/bin/bash
#input
echo "P=$1"
echo "Q=$2"
echo "R=$3"
exit 0
My settings:
[RS274NGC]
SUBROUTINE_PATH = /home/zyz/linuxcnc/nc_files/gladevcp_lib
REMAP =M708 modalgroup=10 argspec=PQR ngc=mytest
My code:
mytest.ngc:
o<mytest> sub
(debug, P word=#<P>)
(debug, Q word=#<Q>)
(debug, R word=#<R>)
o<mytest> endsub
M2
After linuxcnc executes the M code, the output will be displayed in the lower right corner of the interface, but it is not displayed on the Ubuntu terminal.
M708:
#!/bin/bash
#input
echo "P=$1"
echo "Q=$2"
echo "R=$3"
exit 0
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
17 Aug 2021 21:15 #218016
by andypugh
Replied by andypugh on topic Remap M code
I think that you are confusing two ways to create user-defined codes.
M100-M199 can be _any_ executable file. But have no access to internal LinuxCNC data.
Remapped G and M-codes can be written in G-code or in Python.
So, the remap will execute the mytest.ngc but will not execute the script.
If you re-cast the script as a Python routine you could add it as an epilog, which will run after the G-code and which will have access to the parameters.
M100-M199 can be _any_ executable file. But have no access to internal LinuxCNC data.
Remapped G and M-codes can be written in G-code or in Python.
So, the remap will execute the mytest.ngc but will not execute the script.
If you re-cast the script as a Python routine you could add it as an epilog, which will run after the G-code and which will have access to the parameters.
The following user(s) said Thank You: chen1234
Please Log in or Create an account to join the conversation.
- chen1234
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 58
- Thank you received: 2
19 Aug 2021 10:32 #218127
by chen1234
Replied by chen1234 on topic Remap M code
When I use the python script to remap an M code (M708), I cannot receive the parameter value input by MDI. How can I get the parameter value input by MDI?
axis.ini:
[RS274NGC]
# File containing interpreter variables
PARAMETER_FILE = sim.var
SUBROUTINE_PATH = /home/zyz/linuxcnc/configs/sim.axis/python/toplevel.py
REMAP = M708 modalgroup=10 python=m708
[PYTHON]
TOPLEVEL = /home/zyz/linuxcnc/configs/sim.axis/python/toplevel.py
PATH_APPEND = /home/zyz/linuxcnc/configs/sim.axis/python
toplevel.py:
#!/usr/bin/python
import sys
import remap
remap.py:
#!/usr/bin/python
import sys
from interpreter import *
from Tkinter import *
def m708(self,**argv):
print(sys.argv)
axis.ini:
[RS274NGC]
# File containing interpreter variables
PARAMETER_FILE = sim.var
SUBROUTINE_PATH = /home/zyz/linuxcnc/configs/sim.axis/python/toplevel.py
REMAP = M708 modalgroup=10 python=m708
[PYTHON]
TOPLEVEL = /home/zyz/linuxcnc/configs/sim.axis/python/toplevel.py
PATH_APPEND = /home/zyz/linuxcnc/configs/sim.axis/python
toplevel.py:
#!/usr/bin/python
import sys
import remap
remap.py:
#!/usr/bin/python
import sys
from interpreter import *
from Tkinter import *
def m708(self,**argv):
print(sys.argv)
Please Log in or Create an account to join the conversation.
- chen1234
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 58
- Thank you received: 2
19 Aug 2021 10:58 #218130
by chen1234
Replied by chen1234 on topic Remap M code
I found my mistake:
def m708(self,**words):
for key in words:
print("word '%s' = %f" % (key, words[key]))
def m708(self,**words):
for key in words:
print("word '%s' = %f" % (key, words[key]))
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
20 Aug 2021 20:22 #218271
by andypugh
Replied by andypugh on topic Remap M code
You might want to consider using "argspec".
linuxcnc.org/docs/2.8/html/remap/remap.h...he_argspec_parameter
linuxcnc.org/docs/2.8/html/remap/remap.h...he_argspec_parameter
The following user(s) said Thank You: chen1234
Please Log in or Create an account to join the conversation.
Time to create page: 0.209 seconds