On Monday 17 April 2017 16:16:45 Kurt Jacobson wrote:
> Chris,
>
> I am using the user-space Python comp pasted below to get the G20/21
> state out to HAL pins. It looks somewhat similar to what you came up
> with (which makes me feel good as I am just starting to learn python
> and play with LCNC). I sent it to Gene on Saturday, but I guess he did
> not like it ;)
>
Never saw it Kurt, and its not in my inbox or my emc folder here. Did you
get a bounce?
> I brute forced it buy using the python interface and polling every
> 50ms and updating the HAL pins, but I see you used a module GStat,
> where can I find some info on that, it looks useful?
>
> Cheers,
> Kurt
>
> Here is my code:
>
> #!/usr/bin/env python
> import hal, time
> import linuxcnc
>
> stat = linuxcnc.stat()
>
> h = hal.component("units")
> h.newpin("prog_in", hal.HAL_BIT, hal.HAL_OUT)
> h.newpin("prog_mm", hal.HAL_BIT, hal.HAL_OUT)
> h.newpin("update_rate", hal.HAL_FLOAT, hal.HAL_IN)
>
> h.ready()
>
> # Set default update rate to 50ms
> h.update_rate = .05
>
> try:
> while 1:
> time.sleep(h.update_rate)
> stat.poll()
> prog_units = stat.program_units
> if prog_units == 1: # Inch
> h.prog_in = 1
> h.prog_mm = 0
> elif prog_units == 2: # Metric
> h.prog_in = 0
> h.prog_mm = 1
> except KeyboardInterrupt:
> raise SystemExit
>
> On Mon, Apr 17, 2017 at 2:50 PM, Chris Morley
> <[email protected]>
>
> wrote:
> > I think you are using recent master.
> >
> > If so this python program should give you what you want.
> >
> > name it metric_status and put it in your $PATH as per:
> >
> > http://linuxcnc.org/docs/devel/html/hal/halmodule.html
> >
> > Creating Userspace Python Components - LinuxCNC.org<http://linuxcnc.
> > org/docs/devel/html/hal/halmodule.html>
> > linuxcnc.org
> > A userspace component begins by creating its pins and parameters,
> > then enters a loop which will periodically drive all the outputs
> > from the inputs.
> >
> >
> >
> >
> > #!/usr/bin/env python
> > import hal
> > from hal_glib import GStat
> > import gobject
> > GSTAT = GStat()
> >
> > def mode_changed(obj, data):
> > h['g20'] = not data
> > h['g21'] = data
> >
> > h = hal.component("metric_status")
> > h.newpin("g20", hal.HAL_BIT, hal.HAL_OUT)
> > h.newpin("g21", hal.HAL_BIT, hal.HAL_OUT)
> > h.ready()
> >
> > GSTAT.connect("metric-mode-changed",mode_changed)
> > # work around forced merge error
> > GSTAT.merge()
> > metric_new = GSTAT.old['metric']
> > GSTAT.emit('metric_mode_changed',metric_new)
> >
> >
> > try:
> > gobject.MainLoop().run()
> > except KeyboardInterrupt:
> > raise SystemExit
> >
> >
> > ________________________________
> > From: Gene Heskett <[email protected]>
> > Sent: April 16, 2017 12:56 AM
> > To: [email protected]
> > Subject: Re: [Emc-developers] view and mm/inches switching.
> >
> > On Saturday 15 April 2017 19:58:22 andy pugh wrote:
> > > On 16 April 2017 at 00:43, Gene Heskett <[email protected]>
wrote:
> > > > Its a last ditch thought, but not as dynamic as I'd like. I'd
> > > > like very much if it was real time as I have used that switch in
> > > > the middle of a gcode program more than once.
> > >
> > > Do you often care about jog step sizes in the middle of the
> > > execution of a g-code program?
> >
> > Perhaps .1% of the time, most often when there is a tool change or 5
> > in the code.
> >
> > > And do you really want the display switching units when you call a
> > > mm-coded subroutine? I think that would actually just be annoying.
> >
> > Since we can't trace the subroutine at all, and any errors are
> > blamed on the parent call, at least the display changing modes could
> > tell us the subroutine is running. Its a nearly vanishingly thin
> > excuse to be sure though. :(
> >
> > 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)
> > Genes Web page <http://geneslinuxbox.net:6309/gene>
> > [http://geneslinuxbox.net:6309/gene/pix/EasterSundayCropped2004-1.jp
> >g]< http://geneslinuxbox.net:6309/gene>
> >
> > Gene's Web pages<http://geneslinuxbox.net:6309/gene>
> > geneslinuxbox.net
> > Welcome to Gene's web pages. Here you will find some of the things
> > that make me tick, and that help keep me out of the bars. That is me
> > & the missus, Dee (Elladene) I ...
> >
> >
> >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Emc-developers mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/emc-developers
> > Emc-developers Info Page - SourceForge<https://lists.
> > sourceforge.net/lists/listinfo/emc-developers>
> > lists.sourceforge.net
> > The Enhanced Machine Controller (EMC) is a CNC machine controller
> > that runs on Linux and is available under the terms of the GNU
> > General Public License.
> >
> >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Emc-developers mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/emc-developers
>
> ----------------------------------------------------------------------
>-------- Check out the vibrant tech community on one of the world's
> most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Emc-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-developers
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)
Genes Web page <http://geneslinuxbox.net:6309/gene>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers