How to use the le_adc_ReadValue() within an app


#1

hi,

see the topic.

my platform version information:
Legato for WP85/WP75 : 16.10.1.wp85-wp75-native-i686-201702141553

Developer Studio 5.1

I built the project following the Hello-World
helloWorld.c code:

#include "legato.h"
#include"interfaces.h"
COMPONENT_INIT
{
 	int value;
	puts("Hello, world.");
	le_adc_ReadValue(EXT_ADC1,&value) ;
        LE_INFO("The ADC value = %d",value);
}

my .cdef file :

sources:
{
    helloWorld.c
}
requires:
{
    api:
    {
    	le_adc = le_adc.api
    }
}

and the adef file:

executables:
{
    helloWorld = ( helloComponent )
}
processes:
{
    envVars:
    {
        LE_LOG_LEVEL = DEBUG
    }
    run:
    {
        ( helloWorld )
    }
}
bindings:
{
	// I do not what code should I write?
}

Errors:

Description	Resource	Path	Location	Type
Legato builder: ** ERROR: Client interface 'le_adc' of component 'helloComponent' in executable 'helloWorld' is unsatisfied. It must either be declared an external (inter-app) required interface (in a "requires: api:" section in the .adef) or be bound to a server side interface (in the "bindings:" section of the .adef).	helloWorld		 	C/C++ Problem
Symbol 'EXT_ADC1' could not be resolved	helloWorld.c	/helloWorld/helloComponent	line 12	Semantic Error

Please help and give me a clue, thanks.


#2

and my WP Series Development kit information:
MangOH Green – WP8548


#3

And I can read the ADC value by using the command line:
root@swi-mdm9x15:~# legato version
16.04.0_63633d9200de787b7c2a6dca03d2cff3_modified
root@swi-mdm9x15:~# cm adc read EXT_ADC1
EXT_ADC1:42899
root@swi-mdm9x15:~# cm adc read EXT_ADC2
EXT_ADC2:555


#4

Oh my god! :laughing:
the app is working now.:sunglasses::sunglasses:

.c file codes:

#include "legato.h"

#include"interfaces.h"

const char ch1[]="EXT_ADC1";

COMPONENT_INIT
{
	int value;
	puts("Hello, world.");
	le_adc_ReadValue(ch1,&value) ;
	LE_INFO("The ADC value = %d",value);
}

.cdef file codes:

sources:
{
    helloWorld.c
}
requires:
{
    api:
    {
    	le_adc = le_adc.api
    }
}

.adef file codes:

executables:
{
    helloWorld = ( helloComponent )
}

processes:
{
    envVars:
    {
        LE_LOG_LEVEL = DEBUG
    }

    run:
    {
        ( helloWorld )
    }
}

bindings:
{
	helloWorld.helloComponent.le_adc -> modemService.le_adc   //director to modemService , see : http://legato.io/legato-docs/latest/c_adc.html
}

Running:

Jan  6 06:10:04 |  INFO | helloWorld[3666] | Hello, world.
Jan  6 06:10:04 | helloWorld[3666]/framework T=main | le_adc_client.c le_adc_ReadValue() 556 | Sending message to server and waiting for response : 12 bytes sent
Jan  6 06:10:04 | helloWorld[3666]/helloComponent T=main | helloWorld.c _helloComponent_COMPONENT_INIT() 13 | The ADC value = 42902

Thanks!


#5

I tested the adc function, I found that I did not solve my adc_read() issue.:confused:

Because all of the value return are bad values. :confounded:

Can anyone help me? thanks!


#6

OK, I found the bug.:sunglasses:

This is causing the legato version did not compatible with the Legato Package version:

My Legato package version is: 16.10.1.wp85-wp75-native-i686-201702141553
and my Legato wp85 version is: 16.04.0_63633d9200de787b7c2a6dca03d2cff3_modified

So it will need to update my wp85 version to v16.10.1 download from the link: https://source.sierrawireless.com/resources/legato/wpfirmwarerelease13_1/

When I completed the update, the issue was solved.
Now the finally version should be:
Legato Package version: 16.10.1.wp85-wp75-native-i686-201702141553
And the Legato version: 16.10.1_a6a25fbda05738774857dccb9fd76a99_modified

Thank you .