Using remapping code will cause the G code to jump to execute?
15 Dec 2021 11:08 #229111
by chen1234
I have defined multiple remapping codes (M702 is used to set the parameters of external devices, and M200 is used to receive ethercat's io signal and control the movement of the Z axis).
I use (yield INTERP_EXECUTE_FINISH) in the remapping code, which allows my code to be executed sequentially in the file, but when I tested it, I found that only the M702 defined by me would not destroy the G code file.
When using other remapping codes Line skipping will occur (for example, skip the line of G code before M200 when using M200).
Is there a problem with the use of the (yield INTERP_EXECUTE_FINISH) function?
How can I solve it? I use Linuxcnc 2.9
Thank you in advance for any reply.
Below is part of my code and configuration:
remap.pyiningc
I use (yield INTERP_EXECUTE_FINISH) in the remapping code, which allows my code to be executed sequentially in the file, but when I tested it, I found that only the M702 defined by me would not destroy the G code file.
When using other remapping codes Line skipping will occur (for example, skip the line of G code before M200 when using M200).
Is there a problem with the use of the (yield INTERP_EXECUTE_FINISH) function?
How can I solve it? I use Linuxcnc 2.9
Thank you in advance for any reply.
Below is part of my code and configuration:
remap.py
#!/usr/bin/env python3
import sys
import os
from interpreter import *
from emccanon import MESSAGE
import re
import math
import hal
import linuxcnc
import time
import thread
def m200(self,**words):
yield INTERP_EXECUTE_FINISH
if self.task:
a = int(words['p'])
print('a=',a)
x = hal.get_value(lcec.0.5.TXPDO-0)
print("xr ==",x)
if x == 1:
self.execute("G0 Z %d"%a)
print("MDI_Xxxxx")
def m702(self, **words):
yield INTERP_EXECUTE_FINISH
if self.task:
list = []
for key in words:
print("word '%s' = %f" % (key, words[key]))
list.append(key+str(words[key]))
res=str(list[0]+' '+list[1]+' '+list[2])
print ('res=',res)
i=0
while i <= 2:
x=list[i].find("f")
if x != -1:
a = re.sub('[a-zA-Z]',"",list[i])
y=list[i].find("p")
if y != -1:
b = re.sub('[a-zA-Z]',"",list[i])
z=list[i].find("q")
if z != -1:
c = re.sub('[a-zA-Z]',"",list[i])
i+=1
par = str(a+' '+b+' '+c)
print ('parameters=',str(a+' '+b+' '+c))
#main = "/home/.../.../aa" #Executable
#os.system(main +' '+ par)
[PYTHON]
TOPLEVEL = /home/.../linuxcnc/configs/sim.axis/python/toplevel.py
PATH_APPEND = /home/.../linuxcnc/configs/sim.axis/python
[RS274NGC]
# File containing interpreter variables
PARAMETER_FILE = sim.var
SUBROUTINE_PATH = /home/.../linuxcnc/configs//python
REMAP=M702 modalgroup=10 argspec=FPQ python=m702
REMAP=M200 modalgroup=10 argspec=P python=m200
G90
G17
G21
G64 p0.001
F1000
G1 x10 y10 z0
G1 x10 y-10 z0
G1 x0 y0 z0
;M702 F20 P50 Q1
M200 P-5 ;remap code
G2 i5 j0 f1000
M2
Attachments:
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19197
- Thank you received: 6434
15 Dec 2021 12:22 #229117
by tommylight
Replied by tommylight on topic Using remapping code will cause the G code to jump to execute?
Second topic with the same subject ?
Please Log in or Create an account to join the conversation.
15 Dec 2021 12:56 #229124
by cmorley
Replied by cmorley on topic Using remapping code will cause the G code to jump to execute?
starting the remap with 'yield INTERP_EXECUTE_FINISH ' does nothing.
This command should be called _after_ you add your code that needs to wait for events. (such as probing or reading HAL pins)
This command should be called _after_ you add your code that needs to wait for events. (such as probing or reading HAL pins)
Please Log in or Create an account to join the conversation.
Time to create page: 0.205 seconds