- Posts: 4819
- Thank you received: 2177
Seeing values of gcode settings
3 years 5 months ago - 3 years 5 months ago #271521
by Aciera
Replied by Aciera on topic Seeing values of gcode settings
The magic comment does not work.
'Nested comment found'
It seems that it does not like nested brackets in a comment.
'Nested comment found'
It seems that it does not like nested brackets in a comment.
Last edit: 3 years 5 months ago by Aciera.
Please Log in or Create an account to join the conversation.
3 years 5 months ago #271525
by andypugh
Replied by andypugh on topic Seeing values of gcode settings
It seems to be
(py, python code)
or
;py, python code
It calls code here:
github.com/LinuxCNC/linuxcnc/blob/2.8/sr...python_plugin.cc#L67
And multi-line python code can (probably) be passed using "\n"L www.programiz.com/python-programming/methods/built-in/exec
Though if the OP wants to do this a lot, a custom M-code might be easier.
(py, python code)
or
;py, python code
It calls code here:
github.com/LinuxCNC/linuxcnc/blob/2.8/sr...python_plugin.cc#L67
And multi-line python code can (probably) be passed using "\n"L www.programiz.com/python-programming/methods/built-in/exec
Though if the OP wants to do this a lot, a custom M-code might be easier.
Please Log in or Create an account to join the conversation.
3 years 5 months ago #271526
by phillc54
Replied by phillc54 on topic Seeing values of gcode settings
If LinuxCNC is started in a terminal the MDI python method does write to terminal but requires a few commands:
I don't know how to get it to appear in AXIS and I have not tried any other GUI's. I did attempt sending it to stderr but that didn't help.
Code:
;py,import linuxcnc
;py,s=linuxcnc.stat()
;py,s.poll()
;py,print(s.settings[3])
Code:
;py,sys.stderr.write(f"{s.settings[3]}\n")
Please Log in or Create an account to join the conversation.
3 years 5 months ago - 3 years 5 months ago #271529
by Aciera
Replied by Aciera on topic Seeing values of gcode settings
Thanks phil,
For output to axis add:
For output to axis add:
Code:
;py,import emccanon
;py,emccanon.MESSAGE(str(s.settings[3]))
Last edit: 3 years 5 months ago by Aciera. Reason: use MESSAGE instead of CANON_ERROR
The following user(s) said Thank You: phillc54
Please Log in or Create an account to join the conversation.
3 years 5 months ago #271530
by Aciera
Replied by Aciera on topic Seeing values of gcode settings
looks like we can also pass more than one command in a single line:
Code:
;py,emccanon.MESSAGE(str(s.settings[2])),emccanon.MESSAGE(str(s.settings[3]))
Please Log in or Create an account to join the conversation.
3 years 5 months ago #271531
by phillc54
Replied by phillc54 on topic Seeing values of gcode settings
MESSAGE is nice...
It even takes f strings:
It even takes f strings:
Code:
;py,emccanon.MESSAGE(f"G64 P{str(s.settings[3])} Q{str(s.settings[4])}")
Please Log in or Create an account to join the conversation.
Time to create page: 0.059 seconds