Maxime, I don't know what you needed the callback for, but since you are
using the python interface I assume you just want to monitor the LCNC
status.
As part of hazzy I wrote a wrapper for the python interface that permits
registering on-change callbacks for any of the LCNC stat attributes.

For example, to have a function called when the
linuxcnc.stat.tool_in_spindle attribute changes you would do something like
this:

def update_tool(status, tool_num):
    print tool_num
status.on_changed('stat.tool_in_spindle', update_tool)


All the stat attributes are checked once every 50ms, which is plenty fast
for most applications.
You can find some documentation here:
http://hazzy.kcjengr.com/utilities/status_monitor/
Code is here:
https://github.com/KurtJacobson/hazzy/blob/master/hazzy/utilities/status.py

Ideally, it seems like it would be best to have something like this as part
of the python interface ...

Cheers,
Kurt

On Thu, May 17, 2018 at 5:35 PM, Sebastian Kuzminsky <[email protected]>
wrote:

> On 05/17/2018 03:31 PM, Maxime Lemonnier wrote:
>
>> Just want to make sure I did not miss something in the doc. Suppose I
>> wan't
>> to register a python callback from the linuxcnc python module, e.g. once
>> per servo thread, it is not possible, right?
>>
>>
>> def my_function():
>>      print("servo thread tick!")
>>
>> linuxcnc.something.set_callback(my_function);
>>
>
> You're right, that's not possible.  Python modules do not run in realtime
> context, so they don't have a notion of the servo thread or the base thread.
>
> If you write a realtime component (in C, or using the "halcompile" front
> end) its realtime function will get run once per whatever thread you "addf"
> it to, effectively becoming the callback you describe above.
>
>
> --
> Sebastian Kuzminsky
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Emc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-users
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to