Including le_mrc causes errors on very simple app

I’m using the following command to build and install the app. mkapp -t wp77xx -i $LEGATO_ROOT/interfaces/modemServices data_test/data_app.adef && app install data_app.wp77xx.update 192.168.2.2

I’ve tried with and without the -i flag.

Here’s the adef, cdef, and c files, and their directory structure.

data_test
|- cellular
| |- cellular.c
| |- Component.cdef
|- data_app.adef


data_app.adef

start:manual
version: 0.0.1

executables:{
    data_app = (cellular)
}

processes:{
	run:{
		(data_app)
	}
}

bindings:{
	data_app.cellular.le_mrc -> modemService.le_mrc
}

Component.cdef

start:manual
version: 0.0.1

executables:{
	data_app = (cellular)
}

processes:{
	run:{
		(data_app)
	}
}

bindings:{
	data_app.cellular.le_mrc -> modemService.le_mrc
}

cellular.c

#include "legato.h"
#include "interfaces.h"

le_onoff_t cellular_onoff;

COMPONENT_INIT{

	LE_INFO("Will the program even start, or is it the le_mrc api inclusion?");

	for(int i = 0; i<1000; i++){
		usleep(1000);
	}

    le_mrc_ConnectService();

	le_mrc_GetRadioPower(&cellular_onoff);

	if(cellular_onoff == LE_OFF){
		LE_INFO("Modem is off.");
	}else{
		LE_INFO("Modem is on.");
	}

	exit(0);
}

Log output when the program is run. Note the timestamp is not correct.

Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c app_Start() 3469 | Starting app 'data_app'
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/dev/log' to '/legato/systems/current/appsWriteable/data_app/dev/log': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/dev/null' to '/legato/systems/current/appsWriteable/data_app/dev/null': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/dev/zero' to '/legato/systems/current/appsWriteable/data_app/dev/zero': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/dev/urandom' to '/legato/systems/current/appsWriteable/data_app/dev/urandom': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/legato/systems/current/lib/liblegato.so' to '/legato/systems/current/appsWriteable/data_app/lib/liblegato.so': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/lib/ld-linux.so.3' to '/legato/systems/current/appsWriteable/data_app/lib/ld-linux.so.3': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/lib/libc.so.6' to '/legato/systems/current/appsWriteable/data_app/lib/libc.so.6': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/lib/libpthread.so.0' to '/legato/systems/current/appsWriteable/data_app/lib/libpthread.so.0': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/lib/librt.so.1' to '/legato/systems/current/appsWriteable/data_app/lib/librt.so.1': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/lib/libdl.so.2' to '/legato/systems/current/appsWriteable/data_app/lib/libdl.so.2': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/lib/libgcc_s.so.1' to '/legato/systems/current/appsWriteable/data_app/lib/libgcc_s.so.1': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/lib/libm.so.6' to '/legato/systems/current/appsWriteable/data_app/lib/libm.so.6': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/usr/lib/libstdc++.so.6' to '/legato/systems/current/appsWriteable/data_app/lib/libstdc++.so.6': Already exists
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/legato/systems/current/apps/data_app/read-only/lib/libComponent_cellular.so' to '/legato/systems/current/appsWriteable/data_app/lib
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2083 | Skipping file link '/legato/systems/current/apps/data_app/read-only/bin/data_app' to '/legato/systems/current/appsWriteable/data_app/bin/data_app': Alre
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateTmpFs() 1787 | Mounted tmpfs at /legato/systems/current/appsWriteable/data_app/tmp.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2153 | Created file link '/tmp/legato/serviceDirectoryServer' to '/legato/systems/current/appsWriteable/data_app/tmp/legato/serviceDirectoryServer'.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c CreateFileLink() 2153 | Created file link '/tmp/legato/serviceDirectoryClient' to '/legato/systems/current/appsWriteable/data_app/tmp/legato/serviceDirectoryClient'.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | resourceLimits.c GetCfgResourceLimit() 207 | Configured resource limit maxStackBytes is not available.  Using the default value 0.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | proc.c proc_Start() 1403 | Starting process 'data_app' with pid 6272
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | supervisor.c SigChildHandler() 899 | Reaping unconfigured child process 6268.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[6272]/supervisor T=main | proc.c proc_Start() 1363 | Execing 'data_app'
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[6272]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxCoreDumpFileBytes to value 102400.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[6272]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxFileBytes to value 102400.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[6272]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxLockedMemoryBytes to value 8192.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[6272]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxFileDescriptors to value 256.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[6272]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxMQueueBytes to value 512.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[6272]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxThreads to value 20.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[6272]/supervisor T=main | resourceLimits.c SetRLimitValue() 301 | Setting resource limit maxQueuedSignals to value 100.
Jan  7 09:33:01 swi-mdm9x28-wp user.err Legato: =ERR= | serviceDirectory[1077]/serviceDirectory T=main | serviceDirectory.c DispatchToServer() 713 | Client (uid 1027 'appdata_app', pid 6272) disagrees with server (uid 0 'root', pid 1198) on protocol ID of service 'data_app.c
Jan  7 16:33:01 swi-mdm9x28-wp user.emerg Legato: *EMR* | _UNKNOWN_[6272]/framework T=main | messagingSession.c ReceiveSessionOpenResponse() 699 | Unexpected server response: -6 (LE_FAULT).
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | proc.c proc_SigChildHandler() 2079 | Process 'data_app' (PID: 6272) has exited with exit code 1.
Jan  7 09:33:01 swi-mdm9x28-wp user.warn Legato: -WRN- | supervisor[1058]/supervisor T=main | app.c app_SigChildHandler() 4064 | Process 'data_app' in app 'data_app' faulted: Ignored.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | app.c app_StopComplete() 4751 | app 'data_app' has stopped.
Jan  7 09:33:01 swi-mdm9x28-wp user.info Legato:  INFO | supervisor[1058]/supervisor T=main | apps.c DeactivateAppContainer() 374 | Application 'data_app' has stopped.

Everything looks normal until the user level error serviceDirectory[1077]/serviceDirectory T=main | serviceDirectory.c DispatchToServer() 713 | Client (uid 1027 'appdata_app', pid 6272) disagrees with server (uid 0 'root', pid 1198) on protocol ID of service 'data_app.c at which point legato faults and kills the app.

If I remove all references to the mrc api and its function calls, then it compiles and runs just fine. Although if everything is removed then the app does absolutely nothing useful…

It sounds like this error has to do with the IPC protocol of the app. In any case if anyone has any input, I’d love to hear how you overcame this, or a functional workaround.

you can have a look on sample application modemDemo on how to use the le_mrc.

BTW, why do you add the exit(0); in your program?

I’ve read the documentation. I’ve looked through most of the apps in the legato github repository. None of the commit comments indicate problems like this.

To answer the question about why I included exit(0):

  1. Habit
  2. Without exit(0) the app manager doesn’t know the program has finished, and subsequent calls to app status indicate the program is still running.

You can start with the modemdemo app as it should be working fine

“should be working fine” doesn’t mean it’s documented well. This is as much a question of documentation as is it towards why including this API results in a program that compiles but won’t run.

I am sorry that i don’t quite understand why you don’t start with the modemDemo application which already is working fine but sticking with your application which causes errors.

The modemDemo app compiles, and returns the exact same problem as I’ve demonstrated with my code. This is why I pulled back the layers until I skimmed everything I could away from the app. It seems like the inclusion of this API isn’t working.

@dfrey care to chime in?

How did you run the modemDemo app?
In my side, I run the following command
app runProc modemDemo1 send --exe=send -- 1234567 "Online"

After that I can establish data connection in WP76 FW 13.

Fixed it. After recompiling leaf and reflashing the module both programs run fine.