Introduction
Writing new software based on the EnOcean technology or just compile the tutorials and examples provided by the EnOcean Link package it should be available a development environment (better based on Eclipse cross-compiling on Ubuntu Linux) and some other settings are needed. So before starting maybe useful to read these two previous posts:
PiIoT - The perfect reading place #16[tech]: Setup the Raspberry PI Cross-compiler for EnOcean
Easy setup for the Raspberry PI serial
The Raspberry PI 2 Raspbian distribution we are running is the Jessie last update. As starting from this distribution the ttyAMA0 serial port is managed as a service: we should disable it (not enabled at boot) with the command.
sudo systemctl disable serial-getty@ttyAMA0.service
- Disabling the serial needs a reboot. To avoid rebooting the raspberry PI we can also stop the tty service with the command: sudo systemctl stop serial-getty@ttyAMA0.service
- To make the serial port available to the EnOcean gateway without being root user don't forget to change the ttyAMA0 privileges with the command sudo chmod 777 /dev/ttyAMA0
Copying the compiled library to the Raspberry PI
After the EOLink library has been cross compiled in the Eclipse IDE desktop environment we should put it somewhere in the Raspberry PI home folder. Here we refer to the folder
Setting the sources for the Raspberry PI serial
By default the sources of the Tutorial and examples projects of the EnOcean Link package defines the serial port device as USB0
#define SER_PORT "/dev/ttyUSB0"//! the Serial Port Device
To make the programs running on the Raspberry PI we should change this define to the following:
#define SER_PORT "/dev/ttyAMA0"//! the Serial Port Device
This action should be systematically applied to all the sources in both the projects examples and Tutorial. This task can easily be done in the Eclipse IDE environment with the multiple files search and replace as shown in the images below:
Note: not all the sources refers to the ttyUSB0, some other define the serial port as ttyUSB1
As many programs includes some message referring to the USB300 connection port for completeness it is better to replace also this detail with the text ttyAMA0. This operation has not influence on the program functionality or behaviour.
This just one of the most interesting advantages developing and managing a lot of sources on Eclipse desktop environment.
Issue cross compiling EnOcean programs
After everything has been setup correctly we will try to compile en EnOcean provided program. As expected the most simple is just the HelloWorld. All what we should do is to launch the build of the properly set Build Configuration.
At the end of every cross compiling of program that link the EOLink library we get an error !!!
/home/pi/EnOcean/EnOcean Link V1.2.0.0/EOLink/ReleaseLib/../Timer/eoTimer.cpp:44: undefined reference to `clock_gettime'
makefile:44: recipe for target 'Tutorial' failed
collect2: error: ld returned 1 exit status
make: *** [Tutorial] Error 1
To explain this in few words, this seems an known issue related to the time component; it is not a EnOcean software issue but it is of the cross compiler toolchain. There is a library used by the cross compiler that is not of the same version than the one used by the Raspberry PI Debian environment.
As a matter of fact, according with the StackOverflow article How to upgrade glibc from version 2.13 to 2.15 on Debian? - Stack Overflow it is possible to upgrade this library. At the actual date this operation is strongly discouraged as the replacement library is only in the deb http://ftp.debian.org/debian experimental main repository, considered not reliable for any kind of production or normal development environment. If you want to try, it's at your own risk.
Ubuntu desktop development environment for Raspberry PI and EnOcean: conclusion
The described settings and state of the art are subject to almost frequent updates as the open source community constantly work solving problems and issues and upgrading the system. This remain the most proficient development environment I use to develop programs on the Raspberry PI, C/C++ but not only; with few changes it is possible to expand this development environment for Python and Java. The list of the points below tries to focus limits and advantages of this environment.
- Excluding the specific case of the EnOcean applications linking the EOLink library the cross compiling method is faster and more efficient than programming directly on the Raspberry
- The EOLink library itself can be compiled without difficult with the cross-compiles and without errors
- Editing the code in the comfortable environment of the Eclipse source editor, cross-referencing the sources, finding the syntax errors and missing includes and more makes the difference anyway.
- The remote environment (Raspberry PI) remain always connected and accessible to the desktop environment inside the Eclipse IDE. It is extremely easy to move sources or folders from the project to the remote machine and vice-versa.
- Eclipse can also produce good makefiles according with the building configuration and settings.
- All when it is not possible to cross compile the sources due the issue mentioned above it is sufficient keeping a ssh terminal open on the Raspberry to compile on the remote machine in seconds.