On Wednesday 13 November 2019 06:43:36 andy pugh wrote:

> On Wed, 13 Nov 2019 at 11:27, Gene Heskett <[email protected]> 
wrote:
> > Reading the man pages for master as I just built on the rpi4, I
> > still can't find a pin on "motion" that tallies its g20/g21 state.
>
> I don't think motion knows. Motion lives in an entirely metric world.
> G20 / G21 is almost like a preprocessor macro for the interpreter, and
> the G20/G21 status only has any meaning inside the interpreter.
>
> So, it's a G-code status not a machine status.
>
> It wouldn't be hard to make a Python HAL component that gives you the
> units: (Note that this is entirely untested, and written in a Gmail
> window, so the tab-stops should not be trusted either. And I don't
> even know if I have G20 and G21 the right way round,
>
> #!/usr/bin/env python
> import hal, time, linuxcnc
> h = hal.component("units")
> h.newpin("G21", hal.HAL_BIT, hal.HAL_OUT)
> h.newpin("G20", hal.HAL_BIT, hal.HAL_OUT)
> h.ready()
> s = linuxcnc.stat()
> try:
>     while 1:
>         time.sleep(1)
>         s.poll()
>         if s,program_units() == 1:
>               h['G21'] = 0
>               h['G20'] = 1
>         else:
>               h['G21'] = 1
>               h['G20'] = 0
> except KeyboardInterrupt:
>     raise SystemExit

You still haven't written where I should put this other than in a 
non-existent user_comps directory.

So I put it in /home/pi/linuxcnc/configs/sheldon-lathe as units.py.  Then 
fixed a , where I think a . should have been in line 12.
But still getting an error:
Traceback (most recent call last):
  File "/home/pi/linuxcnc/configs/sheldon-lathe/units.py", line 12, in 
<module>
    if s.program_units() == 1:
TypeError: 'int' object is not callable

And thats line 12 and I'm out of ideas on python.


Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page <http://geneslinuxbox.net:6309/gene>


_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to