SOLVED: Trouble getting at the tool table via Python...

More
29 Apr 2020 18:40 #166124 by pferrick
Hi all-

This is probably going to hilight my pathetic efforts to learn python, gtk, GladeVCP etc. all at the same time, but....I'm trying to put values from my tool table into various labels on a GladeVCP side panel.

I have this (among much else which is working) in a file called tools.py:
import linuxcnc as l
s = l.stat()
s.poll()
print s.tool_offset

And when this code runs I get this in the terminal that I ran linuxcnc from:
File "/usr/lib/pymodules/python2.7/gladevcp/tooledit_widget.py", line 161, in reload
    self.hash_code = self.md5sum(self.toolfile)
  File "/usr/lib/pymodules/python2.7/gladevcp/tooledit_widget.py", line 306, in md5sum
    f = open(filename, "rb")
TypeError: coercing to Unicode: need string or buffer, NoneType found
(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)

The thing is that I do have offsets and stuff in my tool file (which exists and is referenced correctly in my .ini file), not the zeros- which tells me (as if the error message didn't!) that it is apparently not being read.

Any suggestions?

tnx,
Patrick

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

More
29 Apr 2020 18:46 #166125 by bbsr_5a
hi
first where do you start this image
this is a Postgui event
so it does not work from main HAL section
then what Gui in general is running Gmocappy or QTpyVCP as it refers to 2.7 python
did you change the name of the tooltable file from ini or tool.tbl still in use

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

More
29 Apr 2020 19:35 #166134 by pferrick
Hello-

Here are some more details: I am running Axis with a GladeVCP side panel. When I load the side panel in my ini file there is python code attached to various buttons. This error message appears when I press a button in my 'Tools' panel, which has a file called tools.py containing a handler for the button press event.

My tool table is called pkf.tools (my initials) which is what is pointed to in my .ini file (TOOL_TABLE = /home/pferrick/pkf.tools or something like that)

Hope that helps a bit...!

Patrick

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

More
29 Apr 2020 19:53 #166135 by pferrick
OK, here's another data point:

When I remove the ToolEditor widget from my GladeVCP panel, the Python error goes away. So that may be a version problem of some sort. Anyway, what I'd like to be able to do is keep track of the Z offsets only, which is why I'm trying to read the tool table in the first place.

I still get (0.0, 0.0, 0.0 etc) from my python code though...

Patrick

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

More
29 Apr 2020 20:38 #166142 by pferrick
Turns out I was getting exactly what I was asking for: the offsets for the current tool. Which, when you don't have a tool loaded is zero!

Plus, I realized that the stat object returns the status of linuxcnc when you poll it. All I need is the contents of the tool table file whenever I read it, which I can get using a basic open() function in Python.

<sigh> If I had _another_ brain, it'd be lonely!!

thanks!

Patrick

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

More
30 Apr 2020 05:56 #166189 by cmorley
What version of linuxcnc are you using?

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

Time to create page: 0.075 seconds
Powered by Kunena Forum