userspace components are just HAL aware normal binaries, using normal scheduling.
Their polling, within the constraints of the scheduling allowed to them, is set in the main function loop.
(in your example the sleep call)

You cannot attach one to a HAL thread.

If you say what you are trying to do, rather than how you are trying to do it, we may be able to help.

There is no compelling reason to use python at all, writing comp components is probably simpler in terms
of usability, 'comp --install component.comp' and voila, it is available like any other component.


On 16/05/19 15:53, mngr wrote:
Hi,

I am trying to build userspace hal components, and I am trying to build them with python.

I can find a lot of examples in the repository calling machinekit.rtapi.loadrt, but I have the vague idea of using machinekit.hal.loadusr

Until now the only solution i have found is something structured like this
#comp file
from machinekit import hal

comp
=hal.component("name")
comp
.newpin("a", HAL.IN , HAL.BIT)

while 1:
  comp
["a"]=comp["b"]
  time
.sleep(1)



and loading

hal.loadusr("comp")



Is this the way it should be used?

I know the hal.addf function, I would like to use it to load function on threads. Is it possible to export function from userspace components? I haven't found any way of exporting functions from python

I would like to write something like that
#comp file
from machinekit import hal

comp
=hal.component("name")
#comp.newpin...

def foo():
  comp
["a"]=comp["b"]

hal
.export(foo)


hal.loadusr("comp")
hal
.addf("foo","servo-thread")



Can you please give me some advice?

mngr












































--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
Visit this group at https://groups.google.com/group/machinekit.
To view this discussion on the web visit https://groups.google.com/d/msgid/machinekit/321cb3b5-7379-447e-8532-063f2e50e47c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
Visit this group at https://groups.google.com/group/machinekit.
To view this discussion on the web visit https://groups.google.com/d/msgid/machinekit/5CDD7EDA.90502%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to