Lets move into the repository you just cloned. Make sure you have all prerequisites mentioned above installed. Now, simply run the following in the repository you just cloned, here called <code>mihini/</code>.

+

Lets move into the repository you just cloned. Make sure you have all prerequisites mentioned above installed. Now, simply run the following in the repository you just cloned, here called <code>mihini-repo/</code>.

<source lang="bash">

<source lang="bash">

# Compile Mihini

# Compile Mihini

−

$ cd mihini/bin

+

$ cd mihini-repo

−

$ ./build.sh

+

$ ./bin/build.sh

−

# Compile Lua

+

# Compile a Lua interpreter

$ cd build.default/

$ cd build.default/

$ make lua

$ make lua

+

# Optional, if you want to use Modbus over serial (e.g. to run the Greenhouse sample)

+

$ make modbus_serial

+

+

# Move the result of the build in your HOME

+

$ mv runtime ~/mihini

</source>

</source>

=== Configure Mihini ===

=== Configure Mihini ===

−

Then there will be some configuration on <code>bin/build.default/runtime/lua/agent/defaultconfig.lua</code>.

+

Now there are some configuration items in <code>~/mihini/lua/agent/defaultconfig.lua</code> that you may optionally want to modify.

−

* Enable the application container

+

−

** <source lang="lua">appcon.activate = true</source>

+

−

* Enable the update manager

+

−

** <source lang="lua">update.activate = true</source>

+

'''OPTIONAL (but useful :))'''

'''OPTIONAL (but useful :))'''

*Enable Lua shell on all network interfaces by <em>adding</em>

*Enable Lua shell on all network interfaces by <em>adding</em>

** <source lang="lua">shell.address = "*"</source>

** <source lang="lua">shell.address = "*"</source>

−

* Disable colors while logging , in order to not clutter your syslog.

+

* Disable colors while logging , in order to not clutter your syslog (log output is shown in /var/log/syslog).

**<source lang="lua">log.enablecolors = false</source>

**<source lang="lua">log.enablecolors = false</source>

+

* Enable the highest logfile output level, this way you can easily see errors in the code

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

'''Notice''': we launched <code>appmon_daemon</code> and <code>mihini</code> with <code>root</code> user rights, and applications managed by <code>appmon_daemon</code> will be launched using user <code>pi</code> 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:

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 <code>main.lua</code>.

+

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&nbsp;:). The file is <code>main.lua</code>.

<source lang="lua">

<source lang="lua">

Line 127:

Line 148:

sched.run(main)

sched.run(main)

sched.loop()

sched.loop()

−

</source>

+

</source>

+

+

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 1 - Build Mihini

So far, all the work is being done directly on your remote system. For the following sample, pi user is being used on a RaspberryPi running Raspbian Wheezy. Connect to you device using ssh and follow the steps.

$ ssh pi@raspberry.local

Compilation prerequisites

First of all, you will need some compilation tools:

$ sudoapt-get install build-essential cmake git telnet

Sources to compile

Run the compilation

Lets move into the repository you just cloned. Make sure you have all prerequisites mentioned above installed. Now, simply run the following in the repository you just cloned, here called mihini-repo/.

# Compile Mihini
$ cd mihini-repo
$ ./bin/build.sh
# Compile a Lua interpreter
$ cd build.default/
$ make lua
# Optional, if you want to use Modbus over serial (e.g. to run the Greenhouse sample)
$ make modbus_serial
# Move the result of the build in your HOME
$ mv runtime ~/mihini

Configure Mihini

Now there are some configuration items in ~/mihini/lua/agent/defaultconfig.lua that you may optionally want to modify.

OPTIONAL (but useful :))

Enable Lua shell on all network interfaces by adding

shell.address ="*"

Disable colors while logging , in order to not clutter your syslog (log output is shown in /var/log/syslog).

log.enablecolors =false

Enable the highest logfile output level, this way you can easily see errors in the code

log.defaultlevel ="DEBUG"-- default log level: can be one of NONE, ERROR, WARNING, INFO, DETAIL, DEBUG, ALL. See log.lua for details

It should be easier

What is explained above is just a beginning. We are about to provide material which will speed up previous steps, such as:

How to cross compile Mihini from your Desktop machine

A defaultconfig.lua with the right default settings

A Linux package, to avoid any kind of compilation or configuration

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

Step 3 - Setup Koneki environment

Define your device and configure its "SSH Lua" paths like this (to reach the presented view, open the Views "Remote Systems" and "Properties". In "Properties" toggle Show Advanced Properties to true, then select "Ssh Lua" from the "Remote Systems" View)

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.

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

Manually

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

Create a launcher

Provide sources

Create a launcher

Mihini Application container runs executables. To run a Lua application, we need to set some variables beforehand and then lauch your application. In order to do so lets create the proper launcher. In the Mihini world, it is an executable file called run. Here is its content:

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 ).