|
On 27/02/17 11:15, Matteo Facchinetti
wrote:
OK, now I understand (I hope...). v1 pins are effectively pointers to a memory area holding their values You should be aware that params are deprecated and now not used in instantiable components at all, just maintained for legacy .comp components. params originally came into being, because pins could not be initialised upon creation to defaults. Now they can, so you should use an IO pin of the relevant type instead.
I can appreciate the desire to work within a model you are familiar with, I used to write a lot in Qt and used the signal/slot mechanisms for callbacks upon event a lot. The realtime polling does not add weight if programmed correctly. There could be problems with not checking for change at the same frequency that it can be set. Doing things in another thread with lower priorities may leave you dealing with changes that have since been superseded. It all depends exactly what you are doing and the frequency of any change and the required reaction time to it. I try to find V2 components but I don't understand where are used.All the instantiable components have counterparts written as v2 (with v2 added before the extension) https://github.com/machinekit/machinekit/blob/master/src/hal/i_components/ At their simplest implementation, they just use pin_ptr s instead of pins and use atomic accessor functions instead of pointer dereferencing. The atomic operations are ones which are indivisible and guaranteed to complete in one hit, which prevents a lot of problems with race conditions when several functions are trying to update or read the same value at the same time. More complicated conditions where values are required to be updated or read across different threads or even different cores can be dealt with by ring_buffers or triple buffers, depending upon the exact need. There are some extremely complex examples in the components, such as https://github.com/machinekit/machinekit/blob/master/src/hal/components/encoderv2.c where Michael Haberler converted it to use atomic functions to pass data between a fast and a slower functions within the component. I am looking at cobbling some documentation together at present, but it is work in progress right now. -- 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. For more options, visit https://groups.google.com/d/optout. |
- [Machinekit] HAL driver dev: call a function whe... Matteo Facchinetti
- Re: [Machinekit] HAL driver dev: call a fun... schooner30@btinternet
- Re: [Machinekit] HAL driver dev: call a... [email protected]
- Re: [Machinekit] HAL driver dev: ca... [email protected]
- Re: [Machinekit] HAL driver dev... Matteo Facchinetti
- Re: [Machinekit] HAL drive... [email protected]
- Re: [Machinekit] HAL d... Matteo Facchinetti
- Re: [Machinekit] HAL driver dev: call a fun... Charles Steinkuehler
