Raspberry Pi is a popular single-board computer that is used for both hardware prototyping and as a flexible component of a bigger media or home data center installations. The fact that it is powerful enough to host a regular Linux system with graphical user interface, games, education packages and lots of other useful stuff, while still being relatively cheap, makes it a very interesting product to play with.
From the programmer's point of view, Raspberry Pi is a regular Linux system (although based on the ARM hardware) and this means that installing or porting existing software most of the time is a straightforward process. The YAMI4 suite of libraries is not different here - it just works out of the box, except for the Python library, which relies on some additional packages. The details are explained below.
Download the current YAMI4 package from the main YAMI4 page. It can be
.tar.gz or
.zip version, the following instructions assume you want to work with the
.tar.gz format.
Put this file somewhere in the RPi's filesystem. In the simplest case it can be in the
/home/pi directory, which is a home directory for the
pi account. There are several possible ways to do it:
$ wget
scpcommand (this requires network connection between RPi and that other machine),
After the file is copied to RPi, log into it and unpack it:
$ tar xzf yami4-gpl-1.10.0.tar.gz $ cd yami4-gpl-1.10.0
The following descriptions assume that the installation starts from that package directory.
The YAMI4 Python library depends on the
python-dev package, which is not installed by default in Raspbian. Depending on how much effort you are willing to invest, there are three ways that lead to the working library:
If you don't want to do anything
Just download these two files and use them with your programs:
yami.py
libyami4py.so
You can do it also directly with (when connected to the internet):
$ wget ... $ wget ...
The
yami.py file is a package that you should
import from your Python scripts, whereas the
libyami4py.so file is the actual engine that deals with messaging, queues and interactions with the operating system (this file was compiled on the Raspberry Pi system, so can be directly used on other RPis). Both files have to be visible to the Python interpreter when running your scripts.
If you want to keep things proper
Log into RPi and install the missing dependency (this requires that your RPi is connected to the internet):
$ sudo apt-get install python-dev
This command will install the Python development files (and some of their dependencies), which are used by YAMI4. Once this is done, you can compile the Python library yourself:
$ cd src/python2 $ make ...
As a result, you should get the
libyami4py.so file, which together with
yami.py form a complete YAMI4 Python package.
If you really want to control everything
The YAMI4 Python library requires a couple of Python header and library files, which are available in the
python2.7-dev package, which itself has several dependencies, from which only two are not met in the default installation:
libexpat1-dev and
libssl-dev. The relevant package files can be obtained from the official repository:
libexpat1-dev_2.1.0-1+deb7u1_armhf.deb
libssl-dev_1.0.1e-2+rvt+deb7u11_armhf.deb
python2.7-dev_2.7.3-6+deb7u2_armhf.deb
Copy these files to RPi (or download them directly from RPi, depending on your networking options) and install them:
$ sudo dpkg -i libexpat1-dev_2.1.0-1+deb7u1_armhf.deb $ sudo dpkg -i libssl-dev_1.0.1e-2+rvt+deb7u11_armhf.deb $ sudo dpkg -i python2.7-dev_2.7.3-6+deb7u2_armhf.deb
Once this is done, you can compile the Python library:
$ cd src/python2 $ make ...
In any case, once you have got both
yami.py and
libyami4py.so files, you can use them from your Python scripts as shown in several examples located in the
src/python2/examples directory. In simple projects you will most likely want to keep these library files in the same directory where the Python scripts are located. Another option is to use environment variables to point the Python interpreter to the right place and this is how the examples are structured - the calculator server can be run with these commands (assuming
192.168.1.175 is the IP address of your RPi):
$ cd examples/print $ PYTHONPATH=../.. python server.py tcp://192.168.1.175:12345
Since Raspberry Pi contains the Java platform installed by default, YAMI4 can be used with Java as well. There is no
ant build tool installed, so either it can be added with appropriate
apt-get command:
$ sudo apt-get install ant
and then
ant can be used to build the YAMI4 library, or the YAMI4 Java source files can be compiled directly:
$ cd src/java/src $ find . -name '*.java' | xargs javac
Note that after doing it, there will be no
.jar file (
ant would build it in the
lib directory of the YAMI4 package), so the source path has to be provided whenever other Java programs are compiled and run with appropriate use of the
-cp option. For example, in order to compile and run the calculator server example, do this:
$ cd ../examples/calculator $ javac -cp ../../src:. *.java $ java -cp ../../src:. Server tcp://192.168.1.175:12345
The last command above assumes that RPi was configured to have the IP address
192.168.1.175.
No special installation steps are required here, the necessary components (the C++ compiler) are already installed as part of the Raspbian system. The standard YAMI4 compilation procedure is:
$ cd src/core $ make ... $ cd ../cpp $ make ...
That's it, the C++ libraries will be put in the
lib directory and all header files will be installed in the
include directory.
With the software packages that are installed in Raspbian by default, you can use YAMI4 in C++ or Java and with very little effort you can also use Python, which seems to be the main language for Raspberry Pi development. In all these cases you will use the general-purpose YAMI4 library, so please check the main YAMI4 page for more detailed documentation and tutorials.
Stay tuned for descriptions on how to use YAMI4 on other single board devices.