Low Level Skeleton Library for IO Communication on GNU/Linux platforms
C/C++ library with bindings to JavaScript and Python to interface with the I/O on the Intel® Galileo board, Intel® Edison board, and other platforms with a structured and sane API where port names/numbering matches the board that you are on. Use of MRAA does not tie you to specific hardware, with board detection done at runtime, you can create portable code that works across multiple platforms.
root@edison:~# opkg install mraa
Package mraa (1.0.0-r0) installed in root is up to date.
root@edison:~#
Hello MRAA
The intent of MRAA is to make it easier for developers and sensor manufacturers to map their sensors & actuators on top of supported hardware and to allow control of low level communication protocol by high level languages & constructs.
Using MRAA and UPM requires to be aware of the versions installed, since there is a version dependency of UPM over MRAA.
To find out know the MRAA version that needs to be installed in order to use UPM, type the following in your edison terminal:
root@edison:~# opkg info mraa
Package: mraa
Version: 0.9.5-r0
Depends: libgcc1 (>= 4.9.1), libpython2.7-1.0 (>= 2.7.3), libc6 (>= 2.20), libft4222 (>= 1)
Status: unknown ok not-installed
Section: libs
Architecture: core2-32
Maintainer: Poky <poky@yoctoproject.org>
MD5Sum: 6eab34356ab6b7561a7221b7bf9ce3c1
Size: 597286
Filename: mraa_0.9.5-r0_core2-32.ipk
Source: git://github.com/intel-iot-devkit/mraa.git;protocol=git;tag=v0.9.5
Description: Low Level Skeleton Library for Communication on Intel platforms Low
Level Skeleton Library for Communication on Intel platforms.
Package: mraa
Version: 1.0.0-r0
Depends: libgcc1 (>= 4.9.1), python-core, libpython2.7-1.0 (>= 2.7.3), libstdc++6 (>= 4.9.)
Status: install ok installed
Section: libs
Architecture: core2-32
Maintainer: Poky <poky@yoctoproject.org>
MD5Sum: 67acedaafba1fc6bb51def2aa3fb6a67
Size: 434934
Filename: mraa_1.0.0-r0_core2-32.ipk
Source: git://github.com/intel-iot-devkit/mraa.git;protocol=git;tag=v1.0.0
Description: Low Level Skeleton Library for Communication on Intel platforms Low
Level Skeleton Library for Communication on Intel platforms.
Installed-Time: 1465260638
root@edison:~#
From there you can see that we need to installed at least version 0.7.0 of MRAA. In the same fashion you can check the version of the installed MRAA library.
This basic MRAA example, can be used to verify it is correctly installed and found by the compiler
root@edison:~# cd TheIoTLearningInitiative/Sensors
root@edison:~/TheIoTLearningInitiative/Sensors#
root@edison:~/TheIoTLearningInitiative/Sensors# mkdir IoTDKL
root@edison:~/TheIoTLearningInitiative/Sensors# cd IoTDKL/
root@edison:~/.../IoTDKL#
root@edison:~/.../IoTDKL# nano HelloMRAA.cpp
#include "mraa.h"
int main(int argc, char** argv)
{
const char* board_name = mraa_get_platform_name();
int i2c_bus, i, i2c_adapter;
fprintf(stdout, "hello mraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);
mraa_deinit();
return MRAA_SUCCESS;
}
How to compile?..let's say you have the code above in a file named HelloMRAA.cpp, inside your edison, now from the Edison terminal type: