erpc icon indicating copy to clipboard operation
erpc copied to clipboard

[QUESTION] User data accessible in function implementation

Open snalvc opened this issue 2 years ago • 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

  • [x] I checked if there is no related issue opened/closed.
  • [x] I checked that there doesn't exist opened/closed PR which is solving this issue.
  • [x] I looked in documentation if there is related information.

snalvc avatar Apr 20 '23 12:04 snalvc

Hi eRPC user. Thank you for your interest and welcome. We hope you will enjoy this framework well.

github-actions[bot] avatar Apr 20 '23 12:04 github-actions[bot]

Hi @snalvc , I don't sure I understand you, If you want some callback, you can see at #313 If you want just to send pointer from client to server, as the server and client may be in different memory spaces, address of one of them is not relevant to the other

amgross avatar Apr 20 '23 14:04 amgross

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.

Hadatko avatar Apr 20 '23 14:04 Hadatko

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

amgross avatar Apr 20 '23 15:04 amgross

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.

Hadatko avatar Apr 20 '23 15:04 Hadatko

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?

snalvc avatar Apr 21 '23 01:04 snalvc

I would expect such change will effect more than the IDL

amgross avatar Apr 23 '23 05:04 amgross