About Hello IPC example api file

Hello,
It’s my first day with legato and I am trying to understand how this platform works.
In the printer.api file is this:

FUNCTION Print
(
string message[100] IN ///< message to be printed into the log.
);

Why do I need to define/great a function here, I can not see where are those called out in components?

In server.c there is the implementation of printer_Print function as I can see
void printer_Print(const char* message)
{
LE_INFO(“******** Client says ‘%s’”, message);
}

and In client.c printer_Print() function is called out

What is the relationship between functions described in printer.api and in components?

All the best

Hi,

You need to define this function in printer.api as when client program is compiled, according to the .adef file, it will know it is a IPC function to call the printer_Print() in server.c.
Also in this definition in printer.api, it will declare the message format to pass from client program to server program.

In the server program’s .cdef file, it declares “printer = printer.api” and in the printer.api, it defines the function Print().
So that is why we need to have a function called printer_Print() in server.c.

For more information, you can have a look here:
http://legato.io/legato-docs/latest/basicAppsIPC.html

Thank you for your replay
now I get it, I don’t know why I thought that printer_Print() is like printerPrint() but it is like prefix that refers the variable printer in cdef and after _ comes the function name defined in api file. All clear now