How to use the ADC in Legato app?

Cross-post from the mangOH forum - as I think this is generic to Legato, and not specific to mangOH?

[quote=“I”]
I don’t see an example of using the ADC in the samples provided in developer studio.

If I just add a call to le_adc_ReadValue() into a ‘Hello World’ example, I get:

If I #include “le_adc_interface.h”, I get:

So what is the correct process to add ADC access to a developer studio project :question:

forum.mangoh.io/t/how-to-use-the … -app/102/1 [/quote]

1 Like

As described in the cross-post, I got it to build - but it doesn’t work.

:frowning:

le_adc_ReadValue() returns -6; which is LE_FAULT = “Unspecified internal error

Any ideas :question:

Awnell,

Please, upgrade your system with last version of legato (16.04.0) and use cm adc read EXT_ADC1 or 2. It work.

Best regards,
Sylvain

Thanks.

Can you confirm that what I’ve done is correct - so it’s just the update that I need?

How do I check the current Legato version on the target?

But that’s a command-line tool, isn’t it :question:

What I need is to read the ADC from within an application.

OK - I found it: legato.io/legato-docs/latest/too … egato.html

[quote]root@swi-mdm9x15:~# legato version
16.01.0.Beta_aa0684bddf31f5ea2d457b53d2218972_modified
root@swi-mdm9x15:~#[/quote]

Yes, it is:

[quote]root@swi-mdm9x15:~# cm adc
ADC usage

To print known adc channels:
cm adc list

To read and print the value from an adc channel:
cm adc read channel
where “channel” is one of the names returned by list

root@swi-mdm9x15:~# cm adc list
Available ADC channels:
EXT_ADC1
EXT_ADC2
root@swi-mdm9x15:~# cm adc read EXT_ADC1
Read EXT_ADC1 failed.
root@swi-mdm9x15:~# cm adc read EXT_ADC2
Read EXT_ADC2 failed.
root@swi-mdm9x15:~#[/quote]

So if this command fails, I guess that explains why my app also failed?

Note that the documentation is incomplete: legato.io/legato-docs/latest/too … get_cm_adc - it refers to “the names returned” but doesn’t say how to get them returned!

after doing the update, the cm adc read command does now seem to work;
but the cm adc list is broken!

[quote]root@swi-mdm9x15:~# cm adc
ADC usage

To print known adc channels:
cm adc read channel
where “channel” is one of the ADC name

root@swi-mdm9x15:~# cm adc list
[color=#FF0000]Invalid command for adc service.[/color]

root@swi-mdm9x15:~# cm adc read EXT_ADC1
EXT_ADC1:43077

root@swi-mdm9x15:~# cm adc read EXT_ADC2
[ 375.439462] qup_i2c qup_i2c.0: QUP: I2C status flags :0x1300c8, irq:187
[ 375.445597] qup_i2c qup_i2c.0: I2C slave addr:0x3a not connected
[ 375.462017] gpio_check_and_wake: wake-n_gpio77 STATE=WAKEUP
EXT_ADC2:301
[ 375.486189] gpio_check_and_wake: wake-n_gpio77 STATE=SLEEP
root@swi-mdm9x15:~# [/quote]

There doesn’t seem to be a package yet for Developer Studio - so my app refuses to start because its Legato version doesn’t match the version running on the target :exclamation:

:angry:

I had Developer Studio 4.0; it needs to be updated to 4.1 - then a Legato 16.4.0 Package becomes available to install …

By George - I do believe we’ve got it :exclamation:

:smiley:

So to get this working required:

[ol]
[li] Firmware 16.04.0 - which was only released on 9 June;[/li]
[li] Developer Studio 4.1 - dated 8 June.[/li][/ol]

Does this mean that I’m the first (outside SiWi) to get this working?! :open_mouth:

hi, awneil,

i have the same issue with the DS 4.0. but i do not know how to upgrade to 4.1.

Can you help me?

regards!

Hi,

the topic is a bit outdated now.
Latest DS release is 5.1 today.
You should be able to upgrade by simply going through Help > Check for Updates menu.

hi, daav,

Thanks.

regards!
2017-04-27

Milo lu-lumao1122

发件人:daav legato1@discoursemail.com
发送时间:2017-04-27 13:57
主题:[Legato Forum] [Legato Application Framework] How to use the ADC in Legato app?

Yes - that post was nearly a year ago now!

If the update doesn’t work, you could just install the latest from scratch …

Hi,
i have an another trouble with the Creat Apps.
i try to build an app follow the basic steps: http://legato.io/legato-docs/latest/basicAppsCreate.html
but it is failed when i run mkapp to build the executable and the boundle it into an app.

mkapp: command not found

How can i fix it? thank you.

Best Regards.
2017-05-04

Milo lu-lumao1122

发件人:daav legato1@discoursemail.com
发送时间:2017-04-27 13:57
主题:[Legato Forum] [Legato Application Framework] How to use the ADC in Legato app?

Hi @lumao

You should start a new topic in order to ask new questions :wink:

1 Like

Indeed.

You can always include a link to this topic if you think it will help in the new one …