- Posts: 140
- Thank you received: 0
SOLVED: Python Interface: getting active gcodes
3 years 3 months ago #275642
by fletch
Python Interface: getting active gcodes was created by fletch
I'm trying to clean up the Manualmatic G5x offset functionality and need to find out if G90 or G91 is active. The Python Interface kindly offers
: "Active G-codes for each modal group. G code constants G_x - G_xxx" so I naively expected a quick
would see me right but it would appear G_90 is not a constant of
(nor is it of
or
.
I also tried a string, as in
but even after explicitly setting G90 via MDI the response is still negative.
Any help in using the
would be greatly appreciated and as a bonus, an understanding of what "for each modal group" means also, because I think that might be relevant...
As a PS, is there an automatically generated 'API doc' for the Python Interface available? The Python Interface doc is really useful but sometimes there's a need to dig a little deeper (and I still can't find the source!)
Code:
linuxcnc.stat.gcodes
Code:
if ( self.linuxcnc.G_90 ) in self.ls.gcodes:
Code:
linuxcnc
Code:
stat
Code:
command
I also tried a string, as in
Code:
if ( "G_90" ) in self.ls.gcodes:
Any help in using the
Code:
linuxcnc.stat.gcodes
As a PS, is there an automatically generated 'API doc' for the Python Interface available? The Python Interface doc is really useful but sometimes there's a need to dig a little deeper (and I still can't find the source!)
Please Log in to join the conversation.
3 years 3 months ago #275645
by rmu
Replied by rmu on topic Python Interface: getting active gcodes
IIRC linuxcnc.stat.gcodes should contain a list of integers, G90 would be 900, G91 910 and so on.
github.com/LinuxCNC/linuxcnc/blob/master...k/taskmodule.cc#L441
Please Log in to join the conversation.
3 years 3 months ago #275647
by meister
Replied by meister on topic Python Interface: getting active gcodes
Code:
import sys
import linuxcnc
try:
s = linuxcnc.stat() # create a connection to the status channel
s.poll() # get current values
except Exception as detail:
print("error", detail)
sys.exit(1)
print(s.gcodes)
if 900 in s.gcodes:
print("G90 active")
elif 910 in s.gcodes:
print("G91 active")
Please Log in to join the conversation.
3 years 3 months ago #275651
by fletch
Replied by fletch on topic SOLVED: Python Interface: getting active gcodes
Many thanks Robert and Oliver - the Python Interface is a little misleading when it describes 'G code constants' as G_90 and G_91 so it didn't occur to me to drop the 'G_'.
Please Log in to join the conversation.
3 years 3 months ago #275689
by cmorley
Replied by cmorley on topic SOLVED: Python Interface: getting active gcodes
Gstat might be useful tool.
linuxcnc.org/docs/2.9/html/gui/gstat.html
linuxcnc.org/docs/2.9/html/gui/gstat.html
Please Log in to join the conversation.
Time to create page: 0.082 seconds
