- Configuring LinuxCNC
- Advanced Configuration
- Raise an error message on loading pure python remappped gcode
Raise an error message on loading pure python remappped gcode
10 Nov 2023 08:41 #285014
by Aciera
I know how to raise an interpreter error if task==1 (ie during actual gcode execution).
This will end code execution with an error message 'my error message here' in the gui:
What I would like to do now is to raise an error message when the gcode is loaded (ie task == 0):
This code will print 'Error -> aborting G68.2' to the terminal but no error is displayed in the gui:
So I assume that emccanon.CANON_ERROR does not work for the interpreter used for creating the preview.
Is there is a way to raise an error message in the standalone interpreter from a python remap?
This will end code execution with an error message 'my error message here' in the gui:
if self.task == 1:
if <some statement is true>:
print('Error -> aborting G68.2')
emccanon.CANON_ERROR( 'G68.2 ERROR: 'my error message here' )
yield INTERP_EXIT
else:
What I would like to do now is to raise an error message when the gcode is loaded (ie task == 0):
This code will print 'Error -> aborting G68.2' to the terminal but no error is displayed in the gui:
if self.task == 0:
if <some statement is true>:
print('Error -> aborting G68.2')
emccanon.CANON_ERROR( 'G68.2 ERROR: 'my error message here' )
yield INTERP_EXIT
else:
So I assume that emccanon.CANON_ERROR does not work for the interpreter used for creating the preview.
Is there is a way to raise an error message in the standalone interpreter from a python remap?
Please Log in or Create an account to join the conversation.
10 Nov 2023 14:52 - 10 Nov 2023 14:57 #285029
by Aciera
Replied by Aciera on topic Raise an error message on loading pure python remappped gcode
Found a solution here:
www.forum.linuxcnc.org/24-hal-components...xcnc?start=10#208679
I created a helper component with an IO pin 'twp_error' that gets written to from my python remap and then cleared in the helper component:
www.forum.linuxcnc.org/24-hal-components...xcnc?start=10#208679
I created a helper component with an IO pin 'twp_error' that gets written to from my python remap and then cleared in the helper component:
try:
while 1:
if h['twp_error'] == 0:
pass
elif h['twp_error'] == 1:
c.error_msg('G68.2 ERROR: TWP already active!')
elif h['twp_error'] == 2:
c.error_msg('G68.2 ERROR: Cannot define TWP from active G59.2 or G59.3 offsets.')
elif h['twp_error'] == 3:
c.error_msg("G68.2 ERROR: Can't enable TWP with G91 active!")
h['twp_error'] = 0
Last edit: 10 Nov 2023 14:57 by Aciera.
Please Log in or Create an account to join the conversation.
10 Nov 2023 15:26 #285031
by Aciera
Replied by Aciera on topic Raise an error message on loading pure python remappped gcode
btw.
I did also try to use the c.error_msg('..') command in the remap itself but this resulted in a very noticeable delay until the message was actually displayed in the gui. The method with the hal pin and the helper component displays the messages instantly.
I did also try to use the c.error_msg('..') command in the remap itself but this resulted in a very noticeable delay until the message was actually displayed in the gui. The method with the hal pin and the helper component displays the messages instantly.
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
10 Nov 2023 19:35 #285042
by cmorley
Replied by cmorley on topic Raise an error message on loading pure python remappped gcode
apparently you can just return a string for an error, but I haven't tried it.
Please Log in or Create an account to join the conversation.
- Configuring LinuxCNC
- Advanced Configuration
- Raise an error message on loading pure python remappped gcode
Time to create page: 0.064 seconds