My answer was not for the “commandLine” sample code (I have just reused this name because it was displayed in your initial post: “/opt/legato/apps/commandLine”).
In order to capture the terminal (console) using fgets, you need to run your Legato app using execInApp.
I succeed to run your application and to capture the console input by using execInApp:
I have created a Legato component called “readStdinComponent”
This component includes a source file called “readStdin.c”:
#define DESTINATION_LEN_MAX 50
fprintf(stderr, "Set Destination Number or command: stop (hang-up), answer (pick-up) or exit to exit of application\n");
fgets ((char*)Destination, DESTINATION_LEN_MAX, stdin);
fprintf(stderr, "Destination= %s !!!\n",Destination);
3) The “Component.cdef” content of this component is:
4) Then I have created a Legato application called “readStdin” which is using the component “readStdinComponent” in order to create an executable called “readStdinExec”.
The content of the application definition file (“readStdin.adef”) is:
readStdinExec = ( readStdinComponent )
5) After building/installing the “readStdin” app on the target, I can run it
[code]root@swi-mdm9x15:~# app status
root@swi-mdm9x15:~# app start readStdin
Starting app ‘readStdin’…
root@swi-mdm9x15:~# execInApp readStdin readStdinExec
Set Destination Number or command: stop (hang-up), answer (pick-up) or exit to exit of application
Destination= answer !!![/code]
As you can see, the “answer” string has been successfully captured from the console.