Introduction
The EnOcean Link library is a set of C++ APIs supporting the EnOcean PIEnOcean PI gateway and the IoT communication protocols between the EnOcean sensors and actuators. The development environment, desktop platform and Eclipse C/C++ IDE settings and configuration mentioned in this article are described in detail in the previous PiIoT - The perfect reading place #16[tech]: Setup the Raspberry PI Cross-compiler for EnOcean
The EnOcean Link library: warnings and issues
As always happens the first time I approach a new embedded technology, issues and problems arrives together. Avoiding that other users interested to this technology meet the same problems it is the worth to write down a short list of tips I have discovered on the run. For better understanding I will add in attach the documents I refer to, including some posts and articles saved in pdf format.
What Raspberry PI should be used
This is the first problem I meet. I have installed several times the EnOcean Link library and compiled it on the Raspberry PI3 as well as the Fhem web serve with very poor results; EnOcean support confirmed me that the PI3 is not 100% allowed (at least not yet) supporting the EnOcean technology and they until now have only tested their software over the PI2. So I have moved the EnOcean gateway on the Raspberry Pi2BRaspberry Pi2B with 16Gb microSD, and the last Raspbian Jessie distribution installed.
Credits
When I had some serious problems compiling the library and other issues with the Fhem web server I should thank to the immediate support through element14Dave that put me in contact with the EnOcean support. Special thanks to markus.kreitmair that investigated in depth the issues and supported me solving them.
How-to a bit confused
I have started checking the available documentation; unfortunately not all the documents was helpful; the complete setting and installation path was deducted picking information here and there after a lot of testing and wrong results. Starting from the Element14 article element14: How to use EnOcean Pi with Raspberry Pi (outdated, it is by three years ago) there is only one is essential information: the link to download the Gateway software.
Finding this document is not so easy: go to the Pi IoT - Smarter Spaces with Raspberry Pi 3: The Kit- UPDATED! showing the list of the components of the kit, including the EnOcean Pi. Clicking on the product in the list (the buy link) you see the documents in the datasheet tab. At that point you can select the Element14 technical page link: 868 MHz Transceiver module for Raspberry Pi using EnOcean TCM 310
This sounds well structured and in the download area you can download the Gateway firmware zip file. Sadly the image below shows the landing page I have reached from this link.
It is mentioned the Gateway firmware download; as firmware I expect the software that in some way will be installed updating the microcontroller or similar (in this case the Atmel micro on board of the EnOcean PI device) The journey trying to find some kind of useful software ended on the Error 404 page; but the article also includes a link to download the EnOcean Link library. For some reasonI have not found any other way to get the link and download the library then this way. After downloading the library, the rest of the documentation seems too outdated to setup a development environment.
Btw, the EnOcean Pi Library can be downloaded from the following link : https://www.element14.com/community/servlet/JiveServlet/download/55295-6-118009/EnOcean+Link+%28Trial%29+V1.2.0.0.zip
Note that it is not excluded that someone else can find an easier and more structured way to find this material.
After the library download this document is almost useless.
Problems and source issues
During his investigations Markus helped me to identify the chip code meaning. If someone else has the same doubts on what is the meaning of the hardware coding consider that it is not related to the version but the numbers refers to the production batch.
About some issues I had trying to work with Fhem version 5.7 and the EnOcean Link gateway it seems depending on some problem of the serial driver. If this issue arises the best workaround is installing the Fhem version 5.5 instead and things should work fine.
In the documentation it is reported a method to disable the /dev/ttyAMA0 serial of the Raspberry PI for the EnOcen PI gateway working. The command sudo rpi-serial-console disable is no longer available in the most recent Raspbian Jessie distribution and should be replaced by one of the following two:
sudo systemctl stop serial-getty@ttyAMA0.service
or
sudo systemctl disable serial-getty@ttyAMA0.service
Use the first to temporarily stop the serial; the original status will be restored on the next boot. To permanently disable the serial instead you should use the second command above.
There is also a source issue documented by Markus as reported below:
a) newtio.c_cc[VMIN] = 1;
a) newtio.c_cflag |= CLOCAL;
b) newtio.c_cflag |= CREAD;
Compiling the EoLink library for the Raspberry Pi
Before starting compiling we should prepare the EOLink package for the Eclipse IDE.
You do not need to decompress che zip package after download. Just copy it somewhere on your development desktop (I have placed it on the Ubuntu Desktop folder.
Importing the EOLink in Eclipse
First we should import the projects in the EOLink library package as Eclipse projects.
From the Eclipse worksspace Project Explorer right click in the project area and select configure to detect new projects (see the image above)
Then select in the dialog wizard Import Projects from File System or Archive (we will use the archived zipped package) browsing to the EOLink zipped folder.
After selecting the zip file you see all the included Eclipse projects.
Select all the proposed projects. The first in the list is the zipped file with the _expanded suffix: it is the folder where Eclipse unzip the package to make the content available for working
At the end of this operation as show in the above image your workspace will include three new projects:
- EOLink - The library tree
- examples - The examples set
- Tutorial - The library tutorials
Preparing the projects build configurations
Before managing and cross compiling the projects we should set them properly for the cross-compiling environment.
Every project includes some different configurations; ignore the Eclipse build all features! We should setup every build configuration for our usage
As shown in the image below right click on the desired project (in this case the EOLink library) and from the Build Configurations contextual menu select Set Active then the desired build configuration from the list. These settings involves the compile and link choices for the project and are independent by any source modification we will apply in future. The Build configuration settings should be applied once as the projects are newly imported; You should remember to make the same changes to any build configuration you will use in future for any project that should be cross compiled for the Raspberry PI.
Setting the cross compiling options for the selected build
As shown in the above image after the desired build configuration has been selected from the project properties you should select the Cross GCC toolchain in the Tool Chain Editor option.
Then, from the same dialog window, in the Setting option select the ToolSettings tab and the first element in the folder list Cross Settings. You should introduce the cross compiler prefix and the full path folder where it is installed in your machine. Accordingly with the previous post indications the two parameters should be:
Prefix settings : arm-linux-gnueabihf-
Path: ~/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian
Special case: the EOLink library
These setting should be applied only to the EOLink project: This is not an executable program but it is the static library linked by any program that should use the EOLink library. Before compiling the library, from the Settings option you should also go to the Build Artifact selecting Type, name, extension and output prefix as shown in the image below.
Patching the library and compiling
Before compiling the EOLink library we should add the patch to the eoLinuxPacketStream.cpp source as explained above. The file is located in the sources tree in EOLink/Packet/eoLinuxPacketStream.cpp starting from line 80:
newtio.c_cflag &= ~PARENB; newtio.c_cflag &= ~CSTOPB; newtio.c_cflag &= ~CSIZE; newtio.c_cflag |= CS8; newtio.c_cflag &= ~CRTSCTS; // === Patch suggested by EnOcean support. Enrico Miglino BlaearicDynamics@gmail.com newtio.c_cflag |= CLOCAL; newtio.c_cflag |= CLOCAL; // === Patch END //Hardware control of port // Blocking: VTIME = 1 // Non-blocking: VTIME = 0 + O_NDELAY newtio.c_cc[VTIME] = blocking ? 1 : 0; // Read-timout 100ms when blocking // === Patch suggested by EnOcean support. Enrico Miglino BlaearicDynamics@gmail.com // newtio.c_cc[VMIN] = 0; newtio.c_cc[VMIN] = 1; // === Patch END tcflush(fd, TCIFLUSH); //Acquire new port settings if (tcsetattr(fd, TCSANOW, &newtio) != 0) puts(strerror(errno)); return EO_OK;
For convenience the patched file is attached to this post
Build the library project
To build the desired project (in this case the EOLink library) we should just Clean and Build the selected build configuration. Also this option is accessible from the project contextual menu.
At the end of the cross-compile process We will find the libEOLink.a static library in the project ReleaseLib folder. At this point we are ready for compiling the desired tutorial and example we see in the other two project trees.
Top Comments