SOLVED: Python Interface: getting active gcodes

More
3 years 3 months ago #275642 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
Code:
linuxcnc.stat.gcodes
: "Active G-codes for each modal group. G code constants G_x - G_xxx" so I naively expected a quick
Code:
if ( self.linuxcnc.G_90 ) in self.ls.gcodes:
would see me right but it would appear G_90 is not a constant of
Code:
linuxcnc
(nor is it of
Code:
stat
or
Code:
command
.

I also tried a string, as in
Code:
if ( "G_90" ) in self.ls.gcodes:
but even after explicitly setting G90 via MDI the response is still negative.

Any help in using the
Code:
linuxcnc.stat.gcodes
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!)

Please Log in to join the conversation.

More
3 years 3 months ago #275645 by rmu
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.

More
3 years 3 months ago #275647 by meister
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.

More
3 years 3 months ago #275651 by fletch
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.

More
3 years 3 months ago #275689 by cmorley

Please Log in to join the conversation.

Time to create page: 0.082 seconds
Powered by Kunena Forum