Get my app version in c/c++ code

Hi,

I tried this:

le_cfg_QuickGetString("/apps/appname/version", version, 256, “unknown”);

no luck, always unknown

Is there a better way to read app version from adef?

adef:

requires:
{
  configTree:
    {
        [r] .
    }
}

Device: FX30(WP7702)
Firmware Version: SWI9X06Y_02.16.06.00 7605a6 jenkins 2018/06/20 17:56:12
Bootloader Version: SWI9X06Y_02.16.06.00 7605a6 jenkins 2018/06/20 17:56:12
MCU Version: 002.009
PRI Revision: 001.000
Carrier PRI Name: GENERIC
Carrier PRI Revision: 001.028_002
Legato version: 18.06.1

You should use the real name of your application, not just appname, unless the name of your application is appname. So, if the name of your application is someApp the code should be something like

char version[256] ;

le_cfg_QuickGetString("/apps/someApp/version", version, sizeof(version), "unknown");

Lets imagine for a minute that i am not a complete idiot and i actually used my real app name (app name is irrelevant to the question) and it still doesn’t work.
What else should i try?

  • If your application is multithreaded, check that the thread calls le_cfg_ConnectService.
  • Check return value of this function, it may clarify the situation
  • Check logs, look for Legato-related errors.
  • Check config tree from shell: config get /apps/someApp/version

Well, most probably, you’ve already took all those steps.

  • Code being called form main thread, i presume le_cfg_ConnectService being called automatically for main thread
  • Always returns LE_OK
  • No error whatsoever in logs
  • It works, returns proper value

Try to grant your application access to the system tree.
For example, in your .adef

requires:
{
  configTree:
    {
        [r] .
        otherApp
    }
}

Tried. As mentioned in my very first post.

adef in your first post looks

requires:
{
  configTree:
    {
        [r] .
    }
}

It grants read access to your own tree, not system tree

Is it some kind of reserved name? Otherwise i don’t understand what should i put there and how it should help.
Sorry i can’t test it right now, problems with my linux machine.

Actually, there are 2 slightly different cases:

  • Sandboxed application
  • Non-sandboxed application

If your application is non-sandboxed, then your original procedure should work, afaik.
In case of sandboxed application, for each application there is its own config tree and you should grant your application access to to those trees. version information is located in system tree, so you should grant access to the system tree.

requires:
{
	configTree:
	{
		[w] .       // I need write access to my configuration data.
		[r] system    // I need read access to system configuration data.
	}
}

But that’s not all. If you’re accessing another tree, you should specify the name of this tree in path argument. So, it should look something like:

char version[256] = "unknown";
le_cfg_QuickGetString("system:/apps/helloWorld/version", version, sizeof(version), version);
1 Like

Yep, it worked!
Thank you very much for your support …and patience :slight_smile:

My pleasure.

Hurmat bilan,
Sasha.