[SOLVED] Custom api stalls app startup

Hi

I have added a custom API to my application so that I should be able to communicate between processes. The reason for this is that I want to be able to let multiple processes read from some gpio pins which is not currently possible with the legato gpio service. I will therefore write my own wrapper service that all my threads can communicate into.
I have tried taking the hello Ipc application and modifying it into a single app with two components which communicate between them over the api. But this results in the startup of the app stalls before my code is started. Can anyone help me figuring out what I’m doing wrong?

I have attached all the relevant source code.
acotest.zip (1.5 KB)

root@swi-mdm9x15:~# logread | grep printClient
Jan 6 01:26:56 swi-mdm9x15 user.info Legato: INFO | updateDaemon[616]/framework T=main | LE_FILENAME user_Create() 1370 | Created user ‘appprintClient’ with uid 1021 and gid 1021.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/dev/log’ to ‘/legato/systems/current/appsWriteable/printClient/dev/log’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/dev/null’ to ‘/legato/systems/current/appsWriteable/printClient/dev/null’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/dev/zero’ to ‘/legato/systems/current/appsWriteable/printClient/dev/zero’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/legato/systems/current/lib/liblegato.so’ to ‘/legato/systems/current/appsWriteable/printClient/lib/liblegato.so’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/lib/ld-linux.so.3’ to ‘/legato/systems/current/appsWriteable/printClient/lib/ld-linux.so.3’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/lib/libc.so.6’ to ‘/legato/systems/current/appsWriteable/printClient/lib/libc.so.6’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/lib/libpthread.so.0’ to ‘/legato/systems/current/appsWriteable/printClient/lib/libpthread.so.0’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/lib/librt.so.1’ to ‘/legato/systems/current/appsWriteable/printClient/lib/librt.so.1’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/lib/libdl.so.2’ to ‘/legato/systems/current/appsWriteable/printClient/lib/libdl.so.2’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/lib/libgcc_s.so.1’ to ‘/legato/systems/current/appsWriteable/printClient/lib/libgcc_s.so.1’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/lib/libm.so.6’ to ‘/legato/systems/current/appsWriteable/printClient/lib/libm.so.6’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/usr/lib/libstdc++.so.6’ to ‘/legato/systems/current/appsWriteable/printClient/lib/libstdc++.so.6’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/legato/systems/current/apps/printClient/read-only/lib/libComponent_printClient.so’ to '/legato/systems/current/appsWriteable/printCli
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/legato/systems/current/apps/printClient/read-only/lib/libComponent_printServer.so’ to '/legato/systems/current/appsWriteable/printCli
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/legato/systems/current/apps/printClient/read-only/bin/client’ to ‘/legato/systems/current/appsWriteable/printClient/bin/client’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/legato/systems/current/apps/printClient/read-only/bin/server’ to ‘/legato/systems/current/appsWriteable/printClient/bin/server’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateTmpFs() 1236 | Mounted tmpfs at /legato/systems/current/appsWriteable/printClient/tmp.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/tmp/legato/serviceDirectoryServer’ to ‘/legato/systems/current/appsWriteable/printClient/tmp/legato/serviceDirectoryServer’.
Jan 6 01:26:59 swi-mdm9x15 user.info Legato: INFO | supervisor[607]/supervisor T=main | app.c CreateFileLink() 1588 | Created file link ‘/tmp/legato/serviceDirectoryClient’ to ‘/legato/systems/current/appsWriteable/printClient/tmp/legato/serviceDirectoryClient’.

Hi @andcor.

Your code looks good to me. I created a new Legato App in DS with your files and only changed one thing - renamed the .adef file to acotest.adef in order to get it to build for me.

I built it using Legato 16.10.3 for a WP85 target. I’ve attached the whole project here so you should be able to rebuild with a later release for any target you need.
acotest_app.zip (182.0 KB)

Here’s the log:

root@swi-mdm9x15:~# logread acotest
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | app.c CreateTmpFs() 1204 | Mounted tmpfs at /legato/systems/current/appsWriteable/acotest/tmp.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | app.c CreateFileLink() 1504 | Created file link '/tmp/legato/serviceDirectoryServer' to '/legato/systems/current/appsWriteable/acotest/tmp/legato/serviceDirectoryServer'.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | app.c CreateFileLink() 1504 | Created file link '/tmp/legato/serviceDirectoryClient' to '/legato/systems/current/appsWriteable/acotest/tmp/legato/serviceDirectoryClient'.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxCoreDumpFileBytes to value 102400.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileBytes to value 102400.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxLockedMemoryBytes to value 8192.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileDescriptors to value 256.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxMQueueBytes to value 512.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxThreads to value 20.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxQueuedSignals to value 100.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | proc.c proc_Start() 1190 | Starting process 'client' with pid 12627
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[12627]/supervisor T=main | proc.c proc_Start() 1155 | Execing 'client'
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxCoreDumpFileBytes to value 102400.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileBytes to value 102400.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxLockedMemoryBytes to value 8192.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxFileDescriptors to value 256.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxMQueueBytes to value 512.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxThreads to value 20.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | resourceLimits.c SetRLimitValue() 282 | Setting resource limit maxQueuedSignals to value 100.
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[1772]/supervisor T=main | proc.c proc_Start() 1190 | Starting process 'server' with pid 12628
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | supervisor[12628]/supervisor T=main | proc.c proc_Start() 1155 | Execing 'server'
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | client[12627]/printClient T=main | client.c _printClient_COMPONENT_INIT() 7 | Asking server to print 'Hello, world!'
Jan  6 00:57:27 swi-mdm9x15 user.info Legato:  INFO | server[12628]/printServer T=main | server.c printer_Print() 6 | ******** Client says 'Hello, world!'

How are you making/building the App? Do you get any build errors?

I’m using legato version 18.04.00. As I remember it I have taken it from a .tar.gz folder and put it into my own repo. The way I’m building it is that I have placed the API file in the interfaces directory and then placed the app under apps and refer to it in the default.sdef.

Then I run make wp750x and see that every app is build. It works for my other apps. But of course there might be differences between the legato version 16.10.3 and 18.04.00.

The latest formal release for WP750x module is Release 15 based on 16.10.4 not 18.04.00.
https://source.sierrawireless.com/resources/airprime/software/wpx5xx/wpx5xx-firmware-latest-release/
Do ensure that the firmware running on the target is Rel15 (based on 16.10.4).

Can you take the latest release package corresponding to this module and tool chain corresponding to this version 15 and check the behaviour?
You can download the legato framework packages and tool chain from the location https://source.sierrawireless.com/resources/airprime/software/wpx5xx/wpx5xx-firmware-latest-release-components/

I suspect there is mismatch in tools or firmware version used causing this issue.

I’m fairly certain that you are correct. We have our own custom yocto build based on the yocto build for the 16.10.4 release. But since we were to build legato separately we thought that it were best to take the newest version of that, but in that we might have been wrong.

I have, however, not been able to build the 16.10.4 version of legato even though I have moved my old toolchain to /opt/swi_bc and installed a new one just as the legato gudes tell me to. I get the following error when I run make:

>make wp750x
Module: WiFi
modules/WiFi/moduleDefs:14: Legato WiFi version is undefined...
********************* VERSION ********************
Legato WiFi version: UNDEFINED
**************************************************
make -f Makefile.hostTools
make[1]: Entering directory '/home/andcor/work/legato-16.10.4'
mkdir -p bin
Using ninja installed at: /usr/bin/ninja
mkdir -p /home/andcor/work/legato-16.10.4/build/tools
export TOOLS_ARCH=x86_64 && \
export HOST_ARCH=x86_64 && \
	framework/tools/mkTools/ninja-generator
Tools arch: x86_64
ln -sf ../build/tools/mk bin/mk
ln -sf mk bin/mkcomp
ln -sf mk bin/mkexe
ln -sf mk bin/mkapp
ln -sf mk bin/mksys
ln -sf ../framework/tools/scripts/findtoolchain ../framework/tools/scripts/instsys ../framework/tools/scripts/settime ../framework/tools/scripts/mkinfo ../framework/tools/scripts/legato-qemu ../framework/tools/scripts/stoplegato ../framework/tools/scripts/settz ../framework/tools/scripts/createsdk ../framework/tools/scripts/instlegato ../framework/tools/scripts/checkpa ../framework/tools/scripts/update-pack ../framework/tools/scripts/security-pack ../framework/tools/scripts/instapp ../framework/tools/scripts/mklegatoimg ../framework/tools/scripts/app ../framework/tools/scripts/av-pack ../framework/tools/scripts/releaselegato ../framework/tools/scripts/sbhelper ../framework/tools/scripts/systocwe ../framework/tools/scripts/configlegatoenv ../framework/tools/scripts/update ../framework/tools/scripts/configtargetssh ../framework/tools/scripts/legs ../framework/tools/scripts/gettargettype ../framework/tools/scripts/update-util ../framework/tools/scripts/configToolchainDirEnvVars ../framework/tools/scripts/simu ../framework/tools/scripts/fwupdate ../framework/tools/scripts/setname ../framework/tools/scripts/mkdoc ../framework/tools/scripts/startlegato ../framework/tools/scripts/shlib bin/
ln -sf ../framework/tools/ifgen/ifgen bin/
ninja  -f /home/andcor/work/legato-16.10.4/build/tools/build.ninja
[1/63] Generating pre-compiled header for mk tools.
FAILED: /home/andcor/work/legato-16.10.4/build/tools/mkTools.h.gch 
g++ -std=c++0x -MMD -MF /home/andcor/work/legato-16.10.4/build/tools/mkTools.h.gch.d  -g -o /home/andcor/work/legato-16.10.4/build/tools/mkTools.h.gch /home/andcor/work/legato-16.10.4/framework/tools/mkTools/mkTools.h
In file included from /home/andcor/work/legato-16.10.4/framework/tools/mkTools/parser/parser.h:52:0,
                 from /home/andcor/work/legato-16.10.4/framework/tools/mkTools/mkTools.h:37:
/home/andcor/work/legato-16.10.4/framework/tools/mkTools/parser/apiParser.h:27:10: error: ‘std::function’ has not been declared
     std::function<void (std::string&&)> handlerFunc ///< Function to call with dependencies.
          ^~~~~~~~
/home/andcor/work/legato-16.10.4/framework/tools/mkTools/parser/apiParser.h:27:18: error: expected ‘,’ or ‘...’ before ‘<’ token
     std::function<void (std::string&&)> handlerFunc ///< Function to call with dependencies.
                  ^
In file included from /home/andcor/work/legato-16.10.4/framework/tools/mkTools/mkTools.h:37:0:
/home/andcor/work/legato-16.10.4/framework/tools/mkTools/parser/parser.h:148:10: error: ‘std::function’ has not been declared
     std::function<parseTree::CompoundItem_t* (Lexer_t& lexer)> contentParserFunc
          ^~~~~~~~
/home/andcor/work/legato-16.10.4/framework/tools/mkTools/parser/parser.h:148:18: error: expected ‘,’ or ‘...’ before ‘<’ token
     std::function<parseTree::CompoundItem_t* (Lexer_t& lexer)> contentParserFunc
                  ^
/home/andcor/work/legato-16.10.4/framework/tools/mkTools/parser/parser.h:167:10: error: ‘std::function’ has not been declared
     std::function<parseTree::CompoundItem_t* (Lexer_t& lexer)> contentParserFunc
          ^~~~~~~~
/home/andcor/work/legato-16.10.4/framework/tools/mkTools/parser/parser.h:167:18: error: expected ‘,’ or ‘...’ before ‘<’ token
     std::function<parseTree::CompoundItem_t* (Lexer_t& lexer)> contentParserFunc
                  ^
ninja: build stopped: subcommand failed.
Makefile.hostTools:37: recipe for target 'tools' failed
make[1]: *** [tools] Error 1
make[1]: Leaving directory '/home/andcor/work/legato-16.10.4'
Makefile:233: recipe for target 'tools' failed
make: *** [tools] Error 2

Which version of linux are you using to build?

Only Ubuntu versions currently supported are officially supported by Legato.
So Ubuntu 12.04 is not for instance.

I am running Xubuntu 18.04. It might be too new, but I think that 16.04 is rather old and 18.04 is also a lts.

Right 16.10.4 is not compatible with 18.04, since we couldn’t make it compatible to something that didn’t exist at the time.

You would need to use a Ubuntu 16.04 to work with that release (can be through a VM or a Docker image as well).

I have chosen to build the gpio part of my application with pure sysfs read, writes and polls. This way I overcome any limitations that legato might have and I do not have to change anything for it to work.