Seeing values of gcode settings

More
3 years 5 months ago - 3 years 5 months ago #271521 by Aciera
The magic comment does not work.
'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.

More
3 years 5 months ago #271525 by andypugh
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.

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

More
3 years 5 months ago #271526 by phillc54
If LinuxCNC is started in a terminal the MDI python method does write to terminal but requires a few commands:
Code:
;py,import linuxcnc ;py,s=linuxcnc.stat() ;py,s.poll() ;py,print(s.settings[3])
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,sys.stderr.write(f"{s.settings[3]}\n")
 

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

More
3 years 5 months ago - 3 years 5 months ago #271529 by Aciera
Thanks phil,
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.

More
3 years 5 months ago #271530 by Aciera
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.

More
3 years 5 months ago #271531 by phillc54
MESSAGE is nice...

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.248 seconds
Powered by Kunena Forum