Difference between revisions of "Mihini/Run Mihini on an Open Hardware platform"

From Eclipsepedia

Jump to: navigation, search
(Step 3 - Setup Koneki environment)
m (Step 3 - Setup Koneki environment)
Line 59: Line 59:
* Install the Mihini Development Tools
* Install the Mihini Development Tools
** Help -> Install new software
** Help -> Install new software
** Work with: <code>http://download.eclipse.org/koneki/updates-nightly</code> **NB:** This stills a nightly build.
** Work with: <code>http://download.eclipse.org/koneki/updates-nightly</code> '''NB:''' This stills a nightly build.
** Select the "Mihini Development Tools for Lua"
** Select the "Mihini Development Tools for Lua"
* Configure the connection to your Raspberry Pi
* Configure the connection to your Raspberry Pi

Revision as of 04:33, 9 July 2013

This page describes a scenario for illustrating the use of Mihini on an Open Hardware Linux-based platform such as BeagleBoard or RaspberryPi.

The goal would be for someone to be able to be only one hour away from taking a bare development board and have it configured to collect data out of the GPIO sensors.

Please bear in mind that Mihini is still under development.


Step 1 - Get Mihini

To get Mihini, you have 3 options :

Step 2 - Start Mihini on your device

One of the features of Mihini is to manage the life cycle of your application. In order to do so, applications are run from another program: the Appmon. We need to start it.

As a service

If you have installed Mihini from a .deb, you have an init script to just do what you want to: /etc/init.d/mihini {start|stop|restart|status|purge}

Or if you have installed Mihini from a .rpm or the AUR (ArchLinux User Repository), you can use systemctl {start|stop|restart|enable|disable} mihini


On your device, if you have built mihini, here a RaspberryPi with user pi.

$ cd  ~/mihini
$ sudo ./bin/appmon_daemon -a /home/pi/mihini/start.sh -w /home/pi/mihini -u pi -g pi -n 5 2>&1 | logger -t Mihini &

Notice: we launched appmon_daemon and mihini with root user rights, and applications managed by appmon_daemon will be launched using user pi that should give sufficient user rights for most of needs.

Possible starting issues The execution of ps aux must show something like the following line to successfully verify that the daemon is running:

root      2360  0.0  0.0   2028   300 pts/0    S+   09:55   0:00 ./bin/appmon_daemon -a /home/pi/mihini/start.sh -w /home/pi/mihini -u pi -g pi -n 5

If this is not the case this may be due to a missing library. Check with ldd bin/appmon_daemon and ldd bin/agent that all required libraries are resolved. If not, try this code

cd /etc/ld.so.conf.d/
sudo /bin/sh -c 'echo "/home/pi/mihini/lib/" > 01-mihini.conf'
sudo ldconfig

Now the respective ldd commands re-executed should resolve.

Stop Mihini manually

$ sudo killall agent appmon_daemon

Step 3 - Setup Koneki environment

  • Download and launch Lua Development Tools
  • Install the Mihini Development Tools
  • Configure the connection to your Raspberry Pi
    • Open the perspective "Remote System explorer"
    • "Define a connection to remote system" -> "Mihini Device"
    • Fill the "Host name" with your Raspberry Pi's IP address, and "Finish"
    • Right clic on "Applications", then "Connect…", and fill your credential

Step 4 - Create your first application

You could blink a LED, use a touch sensor, measure the temperature and available RAM of the board... I decided to keep it simple in this tutorial, my application will simply log :). The file is main.lua.

local log   = require "log"
local sched = require "sched"
local function main()
    log("GENERAL", "INFO", "My first Mihini app is alive :)")

To run the above example, select the main.lua file, right-click Run As/Lua Remote Application, it will then be executed on your Raspberry.

Step 5 - Install your application


All you a have to do in order to enable Mihini to handle you application is:

  1. Create a launcher
  2. Provide sources

Create a launcher

Mihini Application container runs executables. To run a Lua application, we need to create a launcher. In the Mihini world, it is an executable file called run. Here is its content:

lua main.lua

Now the my application folder looks like

$ find raspapp/

Install application

First of all, I presume you already have an Appmon Daemon running. You may wonder which way you can interact with Mihini. While starting, Mihini opens a Telnet server on port 2000, it enables you communicate with its runtime. We are about to use it to install an app available at '/tmp/raspapp', which will be named 'sample', this application will benefit from autostart ( the last true parameter ).

$ telnet localhost 2000
Connected to localhost.
Escape character is '^]'.
Lua interactive shell
> appcon = require 'agent.appcon'
> = appcon.install('sample', '/tmp/raspapp', true)
2013-01-22 13:33:45 APPCON-INFO: Installing application "sample"
= ok

We can check that the application is properly installed

> for app, t in pairs(appcon.list()) do
     print( app )
     for field, data in pairs(t) do
         print("\t", field, data)
                autostart       true
                runnable        true

Notice: CTRL-D to quit.

We can even check logs:

$ tail -f /var/log/syslog | grep Mihini

Over the air

One day, it will be possible to install application to your remote system Mihini just from its IP, and even more:

  • Use the Koneki tools to create an application package
  • Deploy the package on a publically available web server
  • Connect to the Mihini console and for a connection to the testing server


  • You may want to have udev rules so as your USB devices (typically the 3G stick) does not end up having an always changing /dev/ttyUSB<something> file descriptor...
    • For a Sierra 3G stick, create a 99-aircard.rules in /etc/udev/rules.d, with the following rules (your ID_VENDOR_ID and ID_MODEL_ID may be different):


  • Remove Lua comments to save some flash on very tiny devices (could probably be part of the build process btw)
    • find . -type f -name '*.lua' -print0 | xargs -0 sed -i '/^[ \t]*--/d'
  • Strip binary code, to save flash too
    •  find . -type f -name '*.so' -print0 | xargs -0 $STRIP_EXECUTABLE_PATH