SOLVED: Python Interface: getting active gcodes
- fletch
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 131
- Thank you received: 69
17 Jul 2023 11:23 - 17 Jul 2023 11:27 #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 quickwould see me right but it would appear G_90 is not a constant of(nor is it ofor.
I also tried a string, as inbut even after explicitly setting G90 via MDI the response is still negative.
Any help in using thewould 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!)
linuxcnc.stat.gcodes
if ( self.linuxcnc.G_90 ) in self.ls.gcodes:
linuxcnc
stat
command
I also tried a string, as in
if ( "G_90" ) in self.ls.gcodes:
Any help in using the
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!)
Last edit: 17 Jul 2023 11:27 by fletch. Reason: Wrong markup for code
Please Log in or Create an account to join the conversation.
- rmu
- Offline
- Elite Member
Less
More
- Posts: 277
- Thank you received: 100
17 Jul 2023 13:24 - 17 Jul 2023 13:29 #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
Last edit: 17 Jul 2023 13:29 by rmu.
The following user(s) said Thank You: meister, fletch
Please Log in or Create an account to join the conversation.
- meister
- Away
- Platinum Member
Less
More
- Posts: 491
- Thank you received: 309
17 Jul 2023 13:56 #275647
by meister
Replied by meister on topic Python Interface: getting active gcodes
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")
The following user(s) said Thank You: fletch
Please Log in or Create an account to join the conversation.
- fletch
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 131
- Thank you received: 69
17 Jul 2023 14:29 #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 or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7776
- Thank you received: 2073
17 Jul 2023 22:36 #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 or Create an account to join the conversation.
Time to create page: 0.059 seconds