Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[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


Back to the top