Use legato API to open ttyUSB0 and got error

I don’t see problem to printf:

Hi @jyijyi ,

I follow hello1 to modify my test.
I think .adef and .cdef no need to change and I add printf in my first line, then I can’t see the log.
#include <stdio.h>
#include “legato.h”
COMPONENT_INIT
{
printf(“Test printf\n”);

}

So I don’t know why I can’t see the log in my window.
Do I miss something?

are you using unsandboxed feature?
can you run the original hello1.rar?

Hi @jyijyi,

I can run hello1, but I follow hello1.rar to modify my .adef ,.cdef and .c , then there is no changed.

my .adef file like below:

sandboxed: false
start: manual

executables:
{
Larrytest = ( larryComponent )
}

processes:
{
envVars:
{
LE_LOG_LEVEL = DEBUG
}

run:
{
    ( Larrytest )
}
maxCoreDumpFileBytes: 512K
maxFileBytes: 512K

}

version: 1.0.1
maxFileSystemBytes: 512K

and my .cdef

sources:
{
larrytest.c
}

requires:
{

device:
{
[rw] /dev/ttyUSB0 /dev/
}
}
and my .c file

#include “legato.h”
#include <stdio.h>

COMPONENT_INIT
{
printf(“Test printf \n”);
}

you said “I can run hello1”, then if you run it, can you see the same printf like my screenshot?

Hi @jyijyi ,

Yes, I can, but I copy it to my component, then it doesn’t work, so I thought it was weird.

then you port your code to the hello1.rar line by line and see which line makes the problem.

Hi @jyijyi ,

I found the app status is still running when I updated the app.
I always thought the app would stop automatically when I did the update.
But the result did not turn out as I thought.

I think the app is like daemon, it will keep running as background.

You need to use ctrl+c to stop the app if you use “app runProc” to start the app

Hi @jyijyi ,

Thanks for your help.

Now I know how to print to console.

I need ctrl + c and use “app stop XXX”, then the app will really stop.

Hi @jyijyi ,

Sorry I have other question about input arguments.

I run command like “app runProc larrytest larrytest --exe=larrytest -- hello

I think “hello” will input to app.

So I add code in my app like:

LE_INFO(“Num of arg %d”, le_arg_NumArgs());
The result is “Aug 2 03:39:17 fx30 user.info Legato: INFO | Larrytest[2515]/larryComponent T=main | larrytest.c _larryComponent_COMPONENT_INIT() 170 | Num of arg 0”

I don’t know how to input argument.
Please help me thanks.

you should use double hyphen sign

app runProc larrytest larrytest --exe=larrytest -- hello

Hi @jyijyi ,

It may be display error.

you can see this sample code on how to implement le_arg_NumArgs()

you can also see this sample application:

Hi @jyijyi ,

I check .adef and .cdef file is different at “sandboxed: true”

Does it need to sandboxed ?

did you run the sample modemdemo application to verify?

Hi @jyijyi ,

No I didn’t do that because I think it’s too complicated.

Then maybe you should try that

Hi @jyijyi ,

I try to use modemDemo, I update app to device and I don’t know how to use.

I didn’t insert sim card.

you can see here: