Hi,
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”:
[code]#include “legato.h”
#include <stdio.h>
#define DESTINATION_LEN_MAX 50
COMPONENT_INIT
{
LE_INFO(“Hello, world12345.”);
char Destination[DESTINATION_LEN_MAX];
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);
Destination[strlen(Destination)-1]='\0';
fprintf(stderr, "Destination= %s !!!\n",Destination);
}
[/code]
3) The “Component.cdef” content of this component is:
sources:
{
readStdin.c
}
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:
executables:
{
readStdinExec = ( readStdinComponent )
}
5) After building/installing the “readStdin” app on the target, I can run it
[code]root@swi-mdm9x15:~# app status
…
[stopped] readStdin
root@swi-mdm9x15:~# app start readStdin
Starting app ‘readStdin’…
DONE
root@swi-mdm9x15:~# execInApp readStdin readStdinExec
Set Destination Number or command: stop (hang-up), answer (pick-up) or exit to exit of application
answer
Destination= answer !!![/code]
As you can see, the “answer” string has been successfully captured from the console.
Jay