I have been looking at implementing [async] in the cdef file as shown here:
https://legato.io/legato-docs/latest/defFilesCdef.html
Legato 16.10.4
Mangoh green WP85 firmware Rev 15
I have a client and a server, both of which worked, but the client was blocked until the server finished its task. So the server is made asynchronous.
Server TimeComp.API contains:
FUNCTION StartNetTime
(
);
component.CDEF contains:
provides:
{
api:
{
TimeComp = TimeComp.api [async]
}
}
The server main.c contains:
void TimeComp_StartNetTime (TimeComp_ServerCmdRef_t _cmdRef)
{
// execute the code that won’t return for at least 5 seconds
}
The client calls the function:
TimeComp_StartNetTime ();
This seems to work in isolation. The client continues onto the next instruction without blocking.
However, I have been using the event loop after this call… which stops calling anything on the event queue. I set up a sequence of callbacks which work perfectly when I don’t call the asynchronous routine.
The client calls the function:
TimeComp_StartNetTime (); // test the call to async routine
TestCallbacks(); // test all the callbacks in a sequence
None of my callback tests between applications operate at all. When it wasn’t set up as asynchronous, I could see all the callbacks operate, with a 5 second pause whilst the function was blocked.
I have tried using the autogenerated RESPOND function, but it doesn’t like the “implicit call”.
Is there something I have missed about async?
Is the client still waiting for a response from the server?
Is the queue used for the response to come back to the client?
What do I need to do to make it work?