On 24/02/17 18:16, schooner30@btinternet wrote:

On 24/02/17 17:41, Matteo Facchinetti wrote:
Hi,

I'm writing an HAL driver that I want to push when I'll finish but I have a question about RW parameters and the possibility to call a function when user update its value.

In detail, I have a complicated control word with more bits with different meanings and values and a constraint like this:
"if you set a flag, the software should reset others".

I created a parameter for each flags/property that user can control and in my driver I like to call a control function that update the control word each time user update value of the related parameter with setp command.

Is possible to associate a function to the update parameter event?

Just to clarify.
setp does not create an event, it merely directly alters the memory area allocated to the param value.

setp param_name value 
comes out as
rtapi_mutex_get(&(hal_data_mutex));
*(param_name)
= value
rtapi_mutex_give(&(hal_data_mutex));
(with a lot of code missed out)

Unlike higher level abstractions, where a GUI for instance hooks into the underlying sub-system of the window manager
and receives a callback to a nominated function upon an event it is interested in,
the components are based upon kernel modules, which are expected to be stand alone entities, requiring the minimum of external resources.

It is precisely because of this direct 'bit fiddling' in memory referenced from an offset, which is all based upon the x86 memory map, that the multicore
work arose.
The v2 components use accessors to pin_ptrs, instead of direct access to pin values.  They operate through a lock which ensures that only one access can be made
at a time and the value returned is ensured to be the latest one for the pin, via a triple buffer mechanism.
The update of values, still does not trigger an event however.

There are always many ways to do things, but since the component is attached to a thread and polled every thread cycle, it can do its own checking and then
act as appropriate within its own code, upon detecting a relevant change.


The easiest is probably just to store the 'old' value and at every poll, check this against the current
value.
If they are different execute the code you want to.

Just need to make sure you initialise the param value properly when the component starts.


Or is there an other way to make that?


Thanks in advance,

Matteo



--
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.

Reply via email to