I want spiService auto activated

My app need spiService to function. However, when the target complete the boot up, the spiService is not running by default. If I type ‘$app status’ from ssh usb, it shows spiService stopped. I have to manually activate it by typing ‘$app start spiService’.

Is there anyway to configure it to automatically activate it from my app configuration?

you need to set “start” option in .adef:

Is the changes made in my app .adef or in platform spiService app .adef?

why don’t you write a unsanboxed application to just call
system(“app start spiService”);

That seems to be the easiest for you.

Or you can call a script inside the application:

Thanks @jyijyi , the first approach seems more attractive to me, but could you please elaborate?
So I need to make my changes in my .adef? What is the syntax to do:
system(“app start spiService”). A snippet of .adef will be great.

Sorry I am newbie in legato framework :slight_smile:

you can see the unsandboxed app here:

Hmm isn’t this the second approach (calling script)? I was interested first approach, where changes is made in my app definition (that is what I understand from you).

you can change the code inside the system call!!!

hmm ok never mind, thanks for your help anyway.

@babang.parhusip

you can change it in spiService.adef

Thanks @Pankaj , for it take effect, should I rebuild the platform code or the application code?

yes, you need to rebuild the legato.cwe

Ok, rebuilding platform code just to auto activate this spiService is visible but I find it overkill.

I tried alternative by issuing system call in component init like this:

COMPONENT_INIT
{
system(“app start spiService”);

}

but it does not resolve the issue, as the code has no chance to execute. I have to manually type command ‘$app start spiService’ which trigger my app (i.e. COMPONENT_INIT). So where we should put this command?

do you mean it iis not starting the spiService app by system(“app start spiService”)?

How about adding a delay before the system call like sleep(15)?

Adding sleep(15) does not help either.

did you set it to unsandboxed application in adef?

how about system(“echo 123 > /tmp/123.txt”); ???
Can it create the file in /tmp?

in .adef

{
sandboxed:false
}

And the following does not create file
“how about system(“echo 123 > /tmp/123.txt”); ???
Can it create the file in /tmp?”

how about this application?

Can it create the /tmp/123.txt?

BTW, “sandboxed: false” should not be inside { } ?

Can it create the /tmp/123.txt? → No
BTW, “sandboxed: false” should not be inside { } ? → you are right, it was typo. This is right one

image

it is calling system(“/tmp/test.sh”);
Did you place the test.sh in /tmp where this script will create /tmp/123.txt?