Michael Tasche
|
Re: Sending and receiving data from resource manager
|
Michael Tasche
09/04/2019 7:46 AM
post119861
|
Re: Sending and receiving data from resource manager
Hello Thomas,
> Hi
>
> I got a question in Resource manager usage
>
> When we use devctl in the driver to send the data back to the user code (
> client) we use
>
> struct test* = _DEVCTL_DATA(msg->o);
>
> // Code to populate the test structure
>
> if (nbytes == 0) {
> return (_RESMGR_ERRNO (EOK));
> } else {
> msg -> o.ret_val = 0;
> msg -> o.nbytes = nbytes;
> return (_RESMGR_PTR (ctp, &msg -> o, sizeof (msg -> o) + nbytes));
>
> }
>
> with the above code we expect the struct test content will be there in the
> caller function (client)
>
> Q1. Do we need to do memset().. memset(&msg->o, 0, sizeof(msg->o));
No. Well, to be defensive, simply add "msg -> o.zero = msg->o.zero2 = 0"
> If yes why it is needed. ? As i am not understanding where the test data will be stored
> ?
In your code you simply use the input buffer (msg->i) as output buffer (msg->o) for the message reply.
>
> Q2. I am facing a problem where the data is not transfered to the client. How
> to check.?
The devctl cmds. which received data, need the ..._FROM Flag in their definition, otherwise your buffer will not receive
your test struct.
If your test struct is of variable length, you can use the o.ret_val member to return the length.
>
> Q3. When we are passing structure from the Resource manager to the client do
> we need to use _DEVCTL_DATA(msg->o) or
> _DEVCTL_DATA(msg->i)
>
You should use msg->o, but in your case it doesn't matter. devctl IN and OUT message header have the same size.
-Michael
|
|
|