How do I use .api STRING OUT in a function?

Hi,
I have created UART.api containing a function :

FUNCTION UART_Response
(
string MessageOut[100] OUT
);

Then my server app contains the (empty) function:

void UART_UART_Response(char* MessageOut)
{
// code to change the MessageOut contents
}

And the client calls the server app:

char MessageOut[100] = "";
char* MessageOutPtr = &MessageOut[0];
UART_UART_Response(MessageOutPtr);

This call routine sets up an empty string array, and a pointer to the first array element. The client then uses the pointer to send the string’s address to the server for the server to edit the string and return back to the client.

When I compile using mkapp, it complains that there are too few arguments for ‘UART_UART_Response’

I can’t find documentation for IN and OUT for the .api file (other than http://legato.io/legato-docs/latest/apiFilesC.html#apiFilesC_event )

IN uses a string constant
I assume that OUT is to send data back to the client via a variable.

Please could someone clarify what IN and OUT do, and what I should do to pass data back to the client.

Thanks,
Andrew

The api snippet you posted will create a C function like this:

void UART_UART_Response(char *MessageOut, size_t MessageOutLen);

Basically you have to specify how big the buffer is that you pass to the function.

Many thanks for that, it works now that I have put the length in.

Where would I look for the created C function? I guess it is in the _Build directory, but can’t find anything like it.

Regards,
Andrew

It will be in the _build_mangOH_Green directory if you’re buidling for mangOH Green using make green_wp85 from a mangOH working copy. I just did a build and I can see (for example) that the DataRouter’s server interface file is: _build_mangOH_Red/wp85/api/f2b2608ca8891ea78560923a11d23a49/server/dataRouter_server.h.

I don’t recall exactly what that hash is based on, but you can find what you’re looking for by using a command like this:

find _build_mangOH_Green -iname '*uart*_server.h'

Fabulous, thankyou. Just what I needed.

Regards
Andrew