Skip to content
Matt Magoffin edited this page May 13, 2019 · 9 revisions

Using YASDI in SolarNode

SolarNode can make use of the SMA YASDI framework to communicate with SMA inverters. SolarNode provides a yasdi4j bundle (net.solarnetwork.external.yasdi4j) which uses JNI to access the yasdi dynamic library.

Unfortunately, the YASDI driver libraries will not load from the bundle because libyasdi calls dlopen. It must be installed in a location where the SolarNode process can find them.

This setup is not ideal... if anyone knows how to compile the driver libraries directly into YASDI, please chime in!

Getting yasdi libraries

You can download the YASDI shared libraries at https://sourceforge.net/projects/solarnetwork/files/solarnode/yasdi/ which contains the compiled shared libraries and the yasdishell program. Expand this into solar's home directory like

cd ~solar
tar xzf libyasdi-linux-i386.tgz

Setup environment

To get YASDI libraries loading modify the solarnode startup script to include

-Djava.library.path=${SOLARNODE_HOME}/lib

in the JVM_ARGS section. Then modify ~solar/.profile to include

export LD_LIBRARY_PATH=/home/solar/lib

You can run yasdishell if you create a YASDI configuration file. For example create the file ~/conf/yasdi.ini with the following details:

[DriverModules]
Driver0=yasdi_drv_serial

[COM1]
Device=/dev/ttyS0
Media=RS485
Baudrate=1200
Protocol=SMANet

You can then run yasdishell like

yasdishell ~/conf/yasdi.ini

Note that after modifying ~/.profile you might need to log out and back in to pick up the change.

Note on yasdi4j shared libraries

For the JVM to load the shared yasdi4j shared library included in the net.solarnetwork.external.yasdi4j bundle, the file system the shared libraries are installed on must support executables. Normally the /home/solar filesystem will support this, but if the runtime file system is an in-memory file system, such as tmpfs, it might not be configured with executable support and must be changed. In this Debian example, you could update the entry in /etc/fstab to include the exec option, or in the case of tmpfs add an entry to /etc/fstab like this:

tmpfs     /run/shm  tmpfs     rw,nosuid,nodev,exec,relatime,size=50%    0    0

The only difference here is the addition of the exec mount option.

Building yasdi

On the Pi SolarNode, the following software must be installed to build yasdi:

$ sudo apt-get install gcc g++ libc-dev cmake make

Download the YASDI source, and save to a suitable location. It is distributed as a zip archive, e.g. yasdi-1.8.1build9-src.zip. Then

$ mkdir yasdi
$ cd yasdi
$ unzip ../yasdi-1.8.1build9-src.zip
$ cd projects/generic-cmake
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr
$ make && make DESTDIR=$PWD/local install

Package with fpm

$ fpm -s dir -t deb -m 'packaging@solarnetwork.org.nz' --vendor 'SolarNetwork Foundation' \
	-n libyasdi -v 1.8.1-Build9 --description 'Shared libraries for SMA yasdi' \
	--url https://www.sma.de/en/products/monitoring-control/yasdi.html -f -C local --deb-activate noawait \
	usr/lib

$ fpm -s dir -t deb -m 'packaging@solarnetwork.org.nz' --vendor 'SolarNetwork Foundation' \
	-n yasdishell -v 1.8.1-Build9 --description 'Interactive shell for SMA inverters using libyasdi' \
	--url https://www.sma.de/en/products/monitoring-control/yasdi.html -f -C local -d 'libyasdi (>= 1.8.1)' \
	usr/bin
Clone this wiki locally