Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mihini-dev] Lua Remote Application / Mihini GPIO

Ok, I didn’t get you hadn’t used Mihini agent before (at least not explicitly), sorry for that.

 

So Mihini comes with several APIs ( like the Lua framework you’ve been using, or some C APIs too).

Mihini also comes with an agent that helps providing some of the M2M functionalities, like the connection to a M2M server to monitor/manage remotely device(s) etc.

The agent is also used to perform device management operations (like installing and then managing user applications etc).

(You can have an insight of Agent features by looking at http://download.eclipse.org/mihini/doc/ )

Some agent functionalities are executed automatically (or on server request etc), other agent features are exposed as user APIs.

When you use Mihini agent features in an application, you usually have an API that exposes the agent feature but instead of performing it in your application context, the API requests the agent to do it and then gives you the result.

 

Devicetree is one of the agent service, so it requires Mihini agent to be started.

Devicetree enables to share variables across several users (the agent, the server, the user applications etc).

Some variable are provided by default, like agent configuration etc, and you can add some plugins to provide new variables, like there is the GPIO plugin to give access to GPIO through Devicetree.

So when you used devicetree to read GPIO values, the agent actually reads the GPIO, and sends the value to your application.

 

LDT "Run As"  functionality (as opposed to “Lua Application package”) only changes the way the user application is copied/installed, and then started on the device.

The behavior of the APIs is not modified, so DeviceTree API is working the same way using "Run As" , and still needs the agent to work.

 

I hope this helps you understand the links between all those elements.

 

Let’s get back to your use case:

The Mihini agent should be started as a service / daemon automatically if you used .deb files build using Guilhem work.
Given our previous talk, you already used LDT “Lua Application package” feature successfully, so I think the Mihini agent is running on your target.

And reading .deb config files, the agent should be run as root as well.

 

For now, I can’t see the cause of your problem.

 

Let me know if you have more details on my previous questions.

 

Regards,

 

Laurent

 

 

De : mihini-dev-bounces@xxxxxxxxxxx [mailto:mihini-dev-bounces@xxxxxxxxxxx] De la part de mnerys@xxxxxxxxxx
Envoyé : lundi 19 août 2013 16:53
À : Mihini project developer discussions
Objet : Re: [mihini-dev] Lua Remote Application / Mihini GPIO

 

Comments inline... Thanks!

Best,

Marcelo Nery dos Santos
Research Software Engineer

Phone: 55-21-2132-3663
E-mail: mnerys@xxxxxxxxxx

Av. Pasteur 146 & 138
Rio de Janeiro, RJ
22290-240 - Brazil




From:        Laurent Barthelemy <lbarthelemy@xxxxxxxxxxxxxxxxxx>
To:        Mihini project developer discussions <mihini-dev@xxxxxxxxxxx>
Date:        08/19/2013 10:54 AM
Subject:        Re: [mihini-dev] Lua Remote Application / Mihini GPIO
Sent by:        mihini-dev-bounces@xxxxxxxxxxx





Hello Marcelo,
 
I can’t reproduce the issue you reported in your previous mail.
 
Have you started mihini *agent* with sufficient user rights to access GPIO?
[mnerys: I have not started the *agent*, I'm only useng the "Run As" (ssh approach)]
 
You say “I am running this as root”, are you talking about your application, the agent or both?
[mnerys: my application only]
 
I started my agent on my Pi like this:

$ sudo LD_LIBRARY_PATH=/tmp/runtime/lib bin/appmon_daemon -a /tmp/runtime/start.sh -w /tmp/runtime/

(without -v and -h options to appmon_ daemon, this means agent will be started with the same user rights as appmon_ daemon).


Then using LDT « Run As » command, with either LDT Lua SSH configuration set to “pi” user or to “root” user, I can see my led blinking using your code (apart from the GPIO id, not big deal I think).
[mnerys: so, do I have to start the "agent" if I am using the "Run As" approach? From our previous conversations, I thought that these two things were independent.]


You don’t need root user right for your application anymore when using devicetree to access GPIO, only the agent needs root user rights.
 
At this point, I don’t have enough information to help you more.
Can you check:

- agent user rights e.g. by doing :
   telnet device_ip_address 2000
   >  =require"utils.system".pexec("id")

I have:
= uid=0(root) gid=0(root) groups=0(root)

- also check devicetree APIs returned values: init and set calls return “ok” on success, or nil and an error message as string otherwise, so please check you got “ok”, e.g.:
local res,err =
dt.set("system.gpio.18", 0)
[mnerys: I'll investigate this later today, if you let me know the relation between the agent and ssh, maybe things would be a little more clear and work out of the box. Do I have to run the *agent* to use the devicetree? Thanks!]
 
Regards,
 
Laurent
 
 
De : mihini-dev-bounces@xxxxxxxxxxx [mailto:mihini-dev-bounces@xxxxxxxxxxx] De la part de mnerys@xxxxxxxxxx
Envoyé :
mardi 13 août 2013 21:05
À :
Mihini project developer discussions
Objet :
Re: [mihini-dev] Lua Remote Application / Mihini GPIO

 
Hello Laurent,

I have managed to build the devicetree gpio library and it is now loading fine. Thanks Guilhem for helping on that.


Now, it seems I got some issues with the devicetree library. I am running my app via ssh ( "Run As" in LDT ), but I do not see the blinking LED.


My code is as follows:


local
log   = require "log"
local
sched = require "sched"
local
gpio = require "gpio"
local
dt = require "devicetree"

local
function main()
   log("GENERAL", "INFO", "Starting...")

   result, error = dt.init()

   print(result)

   i = 1

   -- local val = gpio.configure(18, {direction="out", edge="none", activelow="0"})

   dt.set("system.gpio.settings.18.direction", "out")

   dt.set("system.gpio.settings.18.edge", "none")

   dt.set("system.gpio.settings.18.activelow", "0")

   while (true) do

     log("GENERAL", "INFO", "My first Mihini app is alive :) oxoxo ".. i)

     i = i + 1

     --gpio.write(18, 1)

     dt.set("system.gpio.18", 1)

     sched.wait(0.1)

     -- gpio.write(18, 0)

     dt.set("system.gpio.18", 0)

     sched.wait(0.1)

   end

end

 
sched
.run(main)
sched
.loop()

I am running this as root and no blinking LED can be seen. If I change it to use the gpio library (the commented out code), it works fine. So, the pin id (18 in my case) should not be the cause of the problem.


Any ideas?


Thanks,


Marcelo Nery dos Santos

Research Software Engineer

Phone: 55-21-2132-3663
E-mail:
mnerys@xxxxxxxxxx

Av. Pasteur 146 & 138
Rio de Janeiro, RJ
22290-240 - Brazil




From:        
mnerys@xxxxxxxxxx
To:        
Mihini project developer discussions <mihini-dev@xxxxxxxxxxx>
Date:        
08/02/2013 02:52 PM
Subject:        
Re: [mihini-dev] Lua Remote Application / Mihini GPIO
Sent by:        
mihini-dev-bounces@xxxxxxxxxxx






Hello Laurent,


Thanks for letting me know about these different behaviours regarding "Export" and "Run As". I've indeed seen some ssh configuration under the "Remote System Explorer", but I thought that for using "Run As > Lua Remote Application", the Mihini agent should have to be started first, which is not actually the case, since ssh is being used instead. I could verify that here using "Run As" after doing a "
sudo killall agent appmon_daemon".

Regarding the ssh root launch, I changed the root password of my Raspberry Pi logging in with the regular "pi" user and doing a "sudo -i". After becoming root, I did a regular passwd to change the password to something I know and could enter in Koneki. With that, the "Run As" worked fine and I could use the GPIO library successfully with the "Run As / Debug As". So, the issue is solved. \o/


I haven't tried the devicetree approach yet, but I'll have a look on it.


Thanks,

Marcelo Nery dos Santos
Research Software Engineer

Phone: 55-21-2132-3663
E-mail:
mnerys@xxxxxxxxxx

Av. Pasteur 146 & 138
Rio de Janeiro, RJ
22290-240 - Brazil




From:        
Laurent Barthelemy <lbarthelemy@xxxxxxxxxxxxxxxxxx>
To:        
Mihini project developer discussions <mihini-dev@xxxxxxxxxxx>
Date:        
08/01/2013 11:40 AM
Subject:        
Re: [mihini-dev] Lua Remote Application / Mihini GPIO
Sent by:        
mihini-dev-bounces@xxxxxxxxxxx






Hi,


Thank you for this feedback!

I’m glad to see the GPIO lib worked well on your Raspberry Pi.


Regarding your remarks:


GPIO mappings:
I understand your comment, and I agree we should help the user understanding this GPIO mapping thing.

However I would rather keep the API doc (
http://download.eclipse.org/mihini/api/lua/gpio.htm ) generic, and add another document, something more like a “tutorial”.
I’m still unsure which form this will take, but we’ll definitively keep the idea!


GPIO and "run as > Lua Remote Application"
I think the issue comes from user right problems.

When Koneki install the application using “Lua Application package”, the application will be installed and start by Mihini Agent, using the parameters you gave to the executable “appmon_daemon”.

It’s a little bit different when you start it as  “Lua Remote Application": Koneki copies and start the application using the SSH connection parameters.

It’s very likely you set up the Remote System Explorer with SSH parameter for user pi, so the the application will be started with user pi when using “Lua Remote Application".


There are several possibilities to change that.

One being, you can edit your Remote System Explorer config to use root (but I think you can’t login/ssh to root by default on raspbian, so you may need to search a way to change that).

Another thing, you can setuid on lua executable in mihini/bin that is used to start Lua application…

I don’t really like much any of those for security concerns…

But, as I would say running as  “Lua Remote Application” is more for testing purpose, maybe It’s no big deal.


You can also change the way you use GPIOs:
-          run Mihini Agent as root and keep application run as pi

-          let Mihini Agent acts on the GPIO using devicetree GPIO lib

o  
you need to activate it doing: “make agent_treemgr_gpio”
-          change your application to use devicetree API to access GPIO

o  
device tree API http://download.eclipse.org/mihini/api/lua/devicetree.html
o  
GPIO device tree variables doc : at the beginning of the source file: http://git.eclipse.org/c/mihini/org.eclipse.mihini.git/tree/agent/agent/treemgr/handlers/gpio.lua

Regards,


Laurent


De :
mihini-dev-bounces@xxxxxxxxxxx [mailto:mihini-dev-bounces@xxxxxxxxxxx] De la part de mnerys@xxxxxxxxxx
Envoyé :
mardi 30 juillet 2013 19:43
À :
Mihini project developer discussions
Objet :
[mihini-dev] Lua Remote Application / Mihini GPIO


Hello All,


I was really glad to see the new Lua GPIO package being available in Mihini. I am already able to make a blinking LED with the Raspberry Pi. \o/


I used the info here:

http://download.eclipse.org/mihini/api/lua/gpio.html

However, at first, it was quite hard to understand how to map the "id" in a call "gpio.write(id, value)" to some actual pin on the device. After some googling, I could find:

http://elinux.org/Rpi_Low-level_peripherals

which made me able to somehow identify the pins and their corresponding ids. So, maybe the page
http://download.eclipse.org/mihini/api/lua/gpio.html could be improved to make it easier for newcomers to get their Pi and start playing directly with Mihini GPIO library.

==


Next, in order to see the blinking LED, I am starting Mihini with the following command (note the "-u root -g root" instead of the usual "-u pi -p pi"):


cd
 ~/mihini
sudo
./bin/appmon_daemon -a /home/pi/mihini/start.sh -w /home/pi/mihini -u root -g root -n 5 2>&1

With this, when I use Koneki to export a Lua Application package and the app starts to run, I can see the blinking LED. I can also see the log of my application being written to the shell I executed the command above.


So, now it comes my question regarding Koneki's ability to remotely run and/or debug a Lua Application. After using Koneki to stop the recently exported application, the log stops along with the blinking LED, as expected. The LED keeps is now in a fixed state (either on/off depending on when the stop occured)).


Going to the Lua perspective in Koneki; right-clicking the main.lua file; and using "run as > Lua Remote Application", I can see the log being written to Koneki's Console view, but the LED does not start flashing.

If I stop the application (by clicking on the "stop" icon close to the "Console view" header and I use the Remote System Explorer perspective to start the app, then everything works again (I can see the log on my shell window and I see the blinking LED).


Any ideas why running the main.lua as a Lua Remote Application is not being able to make the LED blink while still showing the logs and starting the remote process?


My main.lua file looks like this:


--


local
log   = require "log"
local
sched = require "sched"
local
gpio = require "gpio"

local
function main()
 i = 1

 local val = gpio.configure(18, {direction="out", edge="none", activelow="0"})

 while (true) do

   log("GENERAL", "INFO", "My first Mihini app is alive :) oxoxoxo ".. i)

   i = i + 1

   gpio.write(18, 1)

   sched.wait(0.1)

   gpio.write(18, 0)

   sched.wait(0.1)

 end

end


sched
.run(main)
sched
.loop()

--


Thanks,  

Marcelo Nery dos Santos

Research Software Engineer

Phone: 55-21-2132-3663
E-mail:
mnerys@xxxxxxxxxx

Av. Pasteur 146 & 138
Rio de Janeiro, RJ
22290-240 - Brazil



_______________________________________________
mihini-dev mailing list
mihini-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/mihini-dev
_______________________________________________
mihini-dev mailing list
mihini-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/mihini-dev_______________________________________________
mihini-dev mailing list
mihini-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/mihini-dev


Back to the top