How to use the ADC in Legato app?

This forum has moved to http://forum.legato.io

How to use the ADC in Legato app?

Postby awneil » Thu Jun 09, 2016 8:38 am

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

I wrote: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:
implicit declaration of function 'le_adc_ReadValue'


If I #include "le_adc_interface.h", I get:
fatal error: le_adc_interface.h: No such file or directory


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

http://forum.mangoh.io/t/how-to-use-the ... -app/102/1
When I say "SiWi", that's short for "Sierra Wireless".
User avatar
awneil
 
Posts: 6641
Joined: Mon Dec 03, 2007 1:18 pm
Location: Basingstoke, UK
Has thanked: 54 times
Have thanks: 88 times

Re: How to use the ADC in Legato app?

Postby awneil » Thu Jun 09, 2016 5:58 pm

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

:(

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

Any ideas :?:
When I say "SiWi", that's short for "Sierra Wireless".
User avatar
awneil
 
Posts: 6641
Joined: Mon Dec 03, 2007 1:18 pm
Location: Basingstoke, UK
Has thanked: 54 times
Have thanks: 88 times

Re: How to use the ADC in Legato app?

Postby spastor » Fri Jun 10, 2016 2:38 pm

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

For this post the author spastor
has been thanked by :
awneil (Fri Jun 10, 2016 11:33 pm)
spastor
 
Posts: 15
Joined: Fri Oct 23, 2015 4:46 am
Location: LYON
Has thanked: 0 time
Have thanks: 1 time

Re: How to use the ADC in Legato app?

Postby awneil » Fri Jun 10, 2016 5:41 pm

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?
When I say "SiWi", that's short for "Sierra Wireless".
User avatar
awneil
 
Posts: 6641
Joined: Mon Dec 03, 2007 1:18 pm
Location: Basingstoke, UK
Has thanked: 54 times
Have thanks: 88 times

Re: How to use the ADC in Legato app?

Postby awneil » Fri Jun 10, 2016 5:58 pm

spastor wrote:and use cm adc

But that's a command-line tool, isn't it :?:

What I need is to read the ADC from within an application.
When I say "SiWi", that's short for "Sierra Wireless".
User avatar
awneil
 
Posts: 6641
Joined: Mon Dec 03, 2007 1:18 pm
Location: Basingstoke, UK
Has thanked: 54 times
Have thanks: 88 times

Re: How to use the ADC in Legato app?

Postby awneil » Fri Jun 10, 2016 6:05 pm

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

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

root@swi-mdm9x15:~# legato version
16.01.0.Beta_aa0684bddf31f5ea2d457b53d2218972_modified
root@swi-mdm9x15:~#
When I say "SiWi", that's short for "Sierra Wireless".
User avatar
awneil
 
Posts: 6641
Joined: Mon Dec 03, 2007 1:18 pm
Location: Basingstoke, UK
Has thanked: 54 times
Have thanks: 88 times

Re: How to use the ADC in Legato app?

Postby awneil » Fri Jun 10, 2016 6:11 pm

spastor wrote:and use cm adc

I wrote:But that's a command-line tool, isn't it :?:

Yes, it is:
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:~#


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

Note that the documentation is incomplete: http://legato.io/legato-docs/latest/too ... get_cm_adc - it refers to "the names returned" but doesn't say how to get them returned!
When I say "SiWi", that's short for "Sierra Wireless".
User avatar
awneil
 
Posts: 6641
Joined: Mon Dec 03, 2007 1:18 pm
Location: Basingstoke, UK
Has thanked: 54 times
Have thanks: 88 times

Re: How to use the ADC in Legato app?

Postby awneil » Fri Jun 10, 2016 11:07 pm

after doing the update, the cm adc read command does now seem to work;
but the cm adc list is broken!
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
Invalid command for adc service.

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:~#


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 :!:

:x
When I say "SiWi", that's short for "Sierra Wireless".
User avatar
awneil
 
Posts: 6641
Joined: Mon Dec 03, 2007 1:18 pm
Location: Basingstoke, UK
Has thanked: 54 times
Have thanks: 88 times

Re: How to use the ADC in Legato app?

Postby awneil » Fri Jun 10, 2016 11:22 pm

I wrote:There doesn't seem to be a package yet for Developer Studio


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 ...
When I say "SiWi", that's short for "Sierra Wireless".
User avatar
awneil
 
Posts: 6641
Joined: Mon Dec 03, 2007 1:18 pm
Location: Basingstoke, UK
Has thanked: 54 times
Have thanks: 88 times

Re: How to use the ADC in Legato app?

Postby awneil » Fri Jun 10, 2016 11:33 pm

By George - I do believe we've got it :!:

:D
When I say "SiWi", that's short for "Sierra Wireless".
User avatar
awneil
 
Posts: 6641
Joined: Mon Dec 03, 2007 1:18 pm
Location: Basingstoke, UK
Has thanked: 54 times
Have thanks: 88 times

Re: How to use the ADC in Legato app?

Postby awneil » Sat Jun 11, 2016 8:48 am

So to get this working required:

  1. Firmware 16.04.0 - which was only released on 9 June;
  2. Developer Studio 4.1 - dated 8 June.

Does this mean that I'm the first (outside SiWi) to get this working?! :shock:
When I say "SiWi", that's short for "Sierra Wireless".
User avatar
awneil
 
Posts: 6641
Joined: Mon Dec 03, 2007 1:18 pm
Location: Basingstoke, UK
Has thanked: 54 times
Have thanks: 88 times


Return to Legato Application Framework -- MOVED TO FORUM.LEGATO.IO

Who is online

Users browsing this forum: No registered users and 2 guests