[QUESTION] User data accessible in function implementation
Opened this issue · 7 comments
Hi
I'm writing to inquire if eRPC already supports adding user data to the service creation and invocation process. Specifically, I would like to be able to register a void* pointer when creating a service, and then have that pointer passed to the RPC server function implementation in the service. Just like one is able to pass a void* ptr when creating threads/tasks in pthread/FreeRTOS.
Steps you didn't forgot to do
- I checked if there is no related issue opened/closed.
- I checked that there doesn't exist opened/closed PR which is solving this issue.
- I looked in documentation if there is related information.
Hi eRPC user. Thank you for your interest and welcome. We hope you will enjoy this framework well.
Hi,
I think i understand him. Was thinking about some in past. But it would change API for server function implementation.
I think he want have ability to access custom data in function implementation.
idl:
add(int32 number) -> void
server:
void add(int32_t number, void* userData)
{
custom_t *myData = (custom_t *)userData;
myData->sum +=number;
}
Currently you need global variable for doing something like this.
So he want that the caller side API and the callee side will be different? I prefer the way it is today. keep it simple
So he want that the caller side API and the callee side will be different? I prefer the way it is today. keep it simple
I think so.
Yes. What @Hadatko said is exactly what I want.
In my usecase which is FreeRTOS enabled, the eRPC server runs in a task and some of the functions are just cueing other tasks through semaphores and event bits, etc. I want to pass the handle into the server function implementation rather than make the handle a global variable.
I agree braking the commonality between caller and callee API would complicate things. Would it be suitable to add an annotation in IDL which enables such kind of functionality?
I would expect such change will effect more than the IDL