keystroke as a hal pin?

More
11 years 3 weeks ago - 11 years 3 weeks ago #63514 by jtc
Replied by jtc on topic keystroke as a hal pin?

andypugh wrote:

jtc wrote: but I cant find any "commands.send_mdi" that have a string as an argument. or a way to write on the "buffer".


Does this help?
www.linuxcnc.org/docs/html/config/python-interface.html


I already had seen this link, I tryed to use the following code on my .py file:
Code:
import linuxcnc s = linuxcnc.stat() c = linuxcnc.command() def ok_for_mdi(): s.poll() return not s.estop and s.enabled and s.homed and (s.interp_state == linuxcnc.INTERP_IDLE) if ok_for_mdi(): c.mode(linuxcnc.MODE_MDI) c.wait_complete() # wait until mode switch executed c.mdi("G0 X10 Y20 Z30")

hopping to see to be executed on simulation, but without success.

regarding the original idea of the topic, using a keystroke as an hal pin, in axis.py file, next to line 3226 I find this:
Code:
if hal_present == 1 : comp = hal.component("axisui") comp.newpin("jog.x", hal.HAL_BIT, hal.HAL_OUT) comp.newpin("jog.y", hal.HAL_BIT, hal.HAL_OUT) comp.newpin("jog.z", hal.HAL_BIT, hal.HAL_OUT) comp.newpin("jog.a", hal.HAL_BIT, hal.HAL_OUT) comp.newpin("jog.b", hal.HAL_BIT, hal.HAL_OUT) comp.newpin("jog.c", hal.HAL_BIT, hal.HAL_OUT) comp.newpin("jog.u", hal.HAL_BIT, hal.HAL_OUT) comp.newpin("jog.v", hal.HAL_BIT, hal.HAL_OUT) comp.newpin("jog.w", hal.HAL_BIT, hal.HAL_OUT) comp.newpin("jog.increment", hal.HAL_FLOAT, hal.HAL_OUT) comp.newpin("notifications-clear",hal.HAL_BIT,hal.HAL_IN) comp.newpin("notifications-clear-info",hal.HAL_BIT,hal.HAL_IN) comp.newpin("notifications-clear-error",hal.HAL_BIT,hal.HAL_IN) comp.newpin("resume-inhibit",hal.HAL_BIT,hal.HAL_IN)

that create the axisui pins, but if I changed the name of one of these pins, when start linuxcnc I can´t see any difference in axisui pin names.


So, I'm missing something...


João
Last edit: 11 years 3 weeks ago by jtc.
More
11 years 3 weeks ago #63522 by andypugh
Replied by andypugh on topic keystroke as a hal pin?

jtc wrote: if ok_for_mdi():
c.mode(linuxcnc.MODE_MDI)
c.wait_complete() # wait until mode switch executed
c.mdi("G0 X10 Y20 Z30")[/code]


That ought to work, it normally does.
More
11 years 3 weeks ago #63531 by ArcEye
Replied by ArcEye on topic keystroke as a hal pin?

jtc wrote: Hi,
I'm wondering if is possible to assign a keyboard keystroke as an HAL pin? My objective is to use 3 keys, witch one will call a subroutine.

the first will open a log file, the second to log the X and Y coordinates, and finally the third to close the log file. If I can use this with the present keyboard keys it will be great.
Thanks


It is already available as standard in Machinekit, with modifications I added some while ago.

You can assign 10 commands, MDI, HAL or system to the 0 - 9 number keys

See mgware.co.uk/ > Axis Modifications > User Defined Commands to read the details and download the zip.

I have not bothered keeping it current with Linuxcnc versions, but the code should be pretty much unchanged.

regards
More
11 years 3 weeks ago #63537 by jtc
Replied by jtc on topic keystroke as a hal pin?
I will see it.

Thanks
More
11 years 3 weeks ago #63556 by jtc
Replied by jtc on topic keystroke as a hal pin?
it's working successfully :)
Time to create page: 0.286 seconds
Powered by Kunena Forum