From OpenSCADAWiki
Jump to: navigation, search

Name: AdaptAndroid
Founded: February 2017
Status: Android specific expandings of the project OpenSCADA.
Achievement: Packs to APK packages by CrystaxNDKr10 (>= ABI 19, Android 4.4) and NDKr13 (>= ABI 21, Android 5), starts and works through JNI through the WWW and Qt5, tested on DB.Model.AGLKS.
Current difficulty, spent time: 18 (Android) + 4 (OpenSCADA and core libs) + 6(Qt5) days
Members: Roman Savochenko
Description: The sub-project's purpose is to adapt the project OpenSCADA to run on the software platform Android which wide used on more mobile, TV, SmartWatch and other devices.
Task: http://oscada.org/en/development/tasks/posts/tasks_forming_formirovanie_zadach/openscada_adapting_to_the_android_os_tablet_asus_nexus_7_ii_workout.

Logo-Android.png


1 Introduction

Android is an operation system initially developed by Android Inc., which Google bought in 2005, Android was unveiled in 2007, along with the founding of the Open Handset Alliance — a consortium of hardware, software, and telecommunication companies devoted to advancing open standards for mobile devices.

Android's kernel is based on one of the Linux kernel's long-term support (LTS) branches. Since April 2014, Android devices mainly use versions 3.4, 3.10 or 3.18 of the Linux kernel.

Android is far away from a Linux distribution by it does not include the GNU C Library (it uses Bionic as an alternative C library) and some of other components typically found in Linux distributions. Moreover it has a graphical and application stack built on Java VM which excludes initially writing any other program than on the Java language. But in the performance reason JNI uses here to link external native libraries written on C/C++ by a native development kit (NDK). But the LibC Bionic and the core libraries are mostly POSIX compatible. Due more lacks and more limitations into the original Android NDK there was used an user expanded one CrystaX NDK, but last stable version of CrystaX NDK based on NDK r10 and on the task time there allowed original version r13, where more lacks resolved but the native functions of locales still lack.

For developers Google provides Android software development kit (SDK). All projects written to build by Android Development Tools (ADT) and the IDE Eclipse allowed to the packages assemble from the command line and then can be automated, but new projects (see to the current samples) written on/for Android Studio can be built only from the environment and without the command line using. The sub-project implements and tests on Asus Nexus 7 II with the original Android 4.4.4 (Krait) then there uses Andoid-19 SDK version.

Before an action for same OpenSCADA adaption there were read some books, learned some links, created several examples and executed some tests, those are:

  • Read books:
  • Learned links:
  • Built examples from the books, links and Qt5:
    • By ADT into the command line or Eclipse IDE: "san-angeles" (sample), "Store", "DroidBlaster", "LiveCamera", "PortingExecutable", "PortingExecutableBuildSystem", PortingExecutableAUI
    • By Android Studio: "native-activity" (sample), "Store"
    • Qt5 examples: "analogclock", "calculator", "charactermap", "icons", "styles".
  • Built and executed for tests of features of the system:
    • arm_test.cpp — alignment tests of the ARM architecture;
    • locale_test.cpp — time tests with a time zone or UTC;
    • precision_test.cpp — tests for precision of the tasks scheduling (SCHED_RR) in realtime;
    • printf.cpp — tests for performance of different locks: direct RW lock to RD and RW, RW lock wrapped to an object, direct mutex, mutex wrapped to an object.
    • string.cpp — tests for some operations on STL string with exceptions processing.
    • task_test.cpp — tests for threads.

Due the method of linking of native programs is the primarily and exclusively only through JNI by connecting a share library then all dependent code of the program must be placed and pre-loaded into shared libraries against the common one or builtin as the static parts to the common one. Placing and loading the dependent code as the shared libraries will cause to extra memory consumption but it's will exclusively the program's libraries. Then compiling the dependent libraries of the program as the static ones is a preferred way for Android!

2 OpenSCADA

To simplify and early preparing OpenSCADA to JNI in all its parts there is decided to build the program as a native executable and start it from the command-line. Then:

  • To prepare a standalone toolchain for CrystaxNDK r10 there is used the command:
    $ /home/roman/Android/Ndk/build/tools/make-standalone-toolchain.sh --platform=android-19 --install-dir=./TestTCH --system=linux-x86_64 --arch=arm --toolchain=arm-linux-androideabi-5 
    • To init the compiler and the linker there forms an environment preparing script with the SoftFloat and HardFloat flags:
      #!/bin/bash
      
      TARGET=arm-linux-androideabi
      PROJECT=TestTCH
      PRJROOT=/home/roman/Android/$PROJECT
      
      #Soft float
      #export CFLAGS="-O2 -ffunction-sections -funwind-tables -no-canonical-prefixes\
      # -march=armv5te -mfloat-abi=softfp -mfpu=neon -mthumb\
      # -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstack -Wformat -Werror=format-security"
      #export LDFLAGS="-Wl,--fix-cortex-a8"
      #Hard float
      export CFLAGS="-O2 -ffunction-sections -funwind-tables -no-canonical-prefixes\
       -march=armv7-a -mfpu=neon -mhard-float\
       -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstack -Wformat -Werror=format-security"
      export LDFLAGS="-llog -landroid -Wl,--no-warn-mismatch -lm_hard -Wl,--fix-cortex-a8"
      
      export CXXFLAGS="$CFLAGS -fexceptions -frtti"
      
      PREFIX=$PRJROOT
      export PKG_CONFIG_PATH=$PREFIX/sysroot/usr/lib/pkgconfig
      export PATH=$PREFIX/bin:$PATH
      
      #Extended for not autotool
      export CC=$TARGET-gcc
      export LD=$TARGET-ld
      export AS=$TARGET-as
      export AR=$TARGET-ar 
  • To init the compiler directly into the CrystaxNDK r10 tree with the SoftFloat and HardFloat flags:
    #!/bin/bash
    
    NDK_PATH=/home/roman/Android/Ndk
    HOST=linux-x86_64
    TARGET=arm-linux-androideabi
    PLATFORM=android-19
    PLATFORM_LIB_VAR=armeabi-v7a
    TARGET_V=5
    PREFIX=$NDK_PATH/toolchains/$TARGET-$TARGET_V/prebuilt/$HOST
    
    #Soft float
    # -march=armv5te -mfloat-abi=softfp -mfpu=neon -mthumb\
    export CFLAGS="-O2 -ffunction-sections -funwind-tables -no-canonical-prefixes\
     -march=armv7-a -mfloat-abi=softfp -mfpu=vfp\
     -fno-builtin-memmove -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstack -Wformat -Werror=format-security"
    export LDFLAGS="-llog -landroid -Wl,--fix-cortex-a8"
    #Hard float
    #export CFLAGS="-O2 -ffunction-sections -funwind-tables -no-canonical-prefixes\
    # -march=armv7-a -mfpu=vfp -mhard-float\
    # -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstack -Wformat -Werror=format-security"
    #export LDFLAGS="-llog -landroid -Wl,--no-warn-mismatch -lm_hard -Wl,--fix-cortex-a8"
    # -Wl,--no-undefined"
    
    export CFLAGS="$CFLAGS --sysroot=$NDK_PATH/platforms/$PLATFORM/arch-arm/ -I$NDK_PATH/sources/crystax/include\
     -I$NDK_PATH/sources/pcre/include\
     -I$NDK_PATH/sources/openssl/include\
     -I$NDK_PATH/sources/expat/include\
     -I$NDK_PATH/sources/libpng/include\
     -I$NDK_PATH/sources/libjpeg/include\
     -I$NDK_PATH/sources/freetype/include\
     -I$NDK_PATH/sources/fontconfig/include\
     -I$NDK_PATH/sources/libgd2/include\
     -I$NDK_PATH/sources/fftw3/include\
     -I$NDK_PATH/sources/libiconv/include\
     -I$NDK_PATH/sources/gettext/include\
     -I$NDK_PATH/sources/sqlite/include"
    export LDFLAGS="$LDFLAGS -L$NDK_PATH/sources/crystax/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/pcre/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/openssl/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/expat/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/libpng/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/libjpeg/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/freetype/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/fontconfig/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/libgd2/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/fftw3/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/libiconv/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/gettext/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/sqlite/libs/$PLATFORM_LIB_VAR"
    export CXXFLAGS="$CFLAGS -std=c++11 -I$NDK_PATH/sources/cxx-stl/gnu-libstdc++/$TARGET_V/include\
     -I$NDK_PATH/sources/cxx-stl/gnu-libstdc++/$TARGET_V/libs/$PLATFORM_LIB_VAR/include\
     -L$NDK_PATH/sources/cxx-stl/gnu-libstdc++/$TARGET_V/libs/$PLATFORM_LIB_VAR -lgnustl_shared"
    #-lgnustl_static -fexceptions -frtti"
    
    # export PKG_CONFIG="pkg-config --static"
    export PKG_CONFIG_PATH=$NDK_PATH/sources/pkgconfig
    export PATH=$PREFIX/bin:$PATH
    
    #Extended for not autotool
    export CC=$TARGET-gcc
    export LD=$TARGET-ld
    export AS=$TARGET-as
    export AR=$TARGET-ar  
  • To init the compiler directly into the for NDK r13 tree with the SoftFloat and HardFloat flags:
    #!/bin/bash
    
    NDK_PATH=/home/roman/Android/Ndk
    HOST=linux-x86_64
    TARGET=arm-linux-androideabi
    PLATFORM=android-21
    PLATFORM_LIB_VAR=armeabi-v7a
    TARGET_V=4.9
    PREFIX=$NDK_PATH/toolchains/$TARGET-$TARGET_V/prebuilt/$HOST
    
    #Soft float
    # -march=armv5te -mfloat-abi=softfp -mfpu=neon -mthumb\
    export CFLAGS="-O2 -ffunction-sections -funwind-tables -no-canonical-prefixes\
     -march=armv7-a -mfloat-abi=softfp -mfpu=vfp\
     -fno-builtin-memmove -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstack -Wformat -Werror=format-security"
    export LDFLAGS="-llog -landroid -lm -Wl,--fix-cortex-a8"
    #Hard float
    #export CFLAGS="-O2 -ffunction-sections -funwind-tables -no-canonical-prefixes\
    # -march=armv7-a -mfpu=vfp -mhard-float\
    # -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstack -Wformat -Werror=format-security"
    #export LDFLAGS="-llog -landroid -Wl,--no-warn-mismatch -lm_hard -Wl,--fix-cortex-a8"
    # -Wl,--no-undefined"
    
    export CFLAGS="$CFLAGS --sysroot=$NDK_PATH/platforms/$PLATFORM/arch-arm/\
     -I$NDK_PATH/sources/pcre/include\
     -I$NDK_PATH/sources/openssl/include\
     -I$NDK_PATH/sources/expat/include\
     -I$NDK_PATH/sources/libpng/include\
     -I$NDK_PATH/sources/libjpeg/include\
     -I$NDK_PATH/sources/freetype/include\
     -I$NDK_PATH/sources/fontconfig/include\
     -I$NDK_PATH/sources/libgd2/include\
     -I$NDK_PATH/sources/fftw3/include\
     -I$NDK_PATH/sources/libiconv/include\
     -I$NDK_PATH/sources/gettext/include\
     -I$NDK_PATH/sources/sqlite/include"
    export LDFLAGS="$LDFLAGS\
     -L$NDK_PATH/sources/pcre/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/openssl/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/expat/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/libpng/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/libjpeg/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/freetype/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/fontconfig/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/libgd2/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/fftw3/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/libiconv/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/gettext/libs/$PLATFORM_LIB_VAR\
     -L$NDK_PATH/sources/sqlite/libs/$PLATFORM_LIB_VAR"
    export CXXFLAGS="$CFLAGS -std=c++11 -I$NDK_PATH/sources/cxx-stl/gnu-libstdc++/$TARGET_V/include\
     -I$NDK_PATH/sources/cxx-stl/gnu-libstdc++/$TARGET_V/libs/$PLATFORM_LIB_VAR/include\
     -L$NDK_PATH/sources/cxx-stl/gnu-libstdc++/$TARGET_V/libs/$PLATFORM_LIB_VAR -lgnustl_shared"
    
    # export PKG_CONFIG="pkg-config --static"
    export PKG_CONFIG_PATH=$NDK_PATH/sources/pkgconfig
    export PATH=$PREFIX/bin:$PATH
    
    #Extended for not autotool
    export CC=$TARGET-gcc
    export LD=$TARGET-ld
    export AS=$TARGET-as
    export AR=$TARGET-ar
  • Before same OpenSCADA compile we need compile:
    • the PCRE library by the command:
      $ ./configure --host=arm-linux-androideabi --disable-cpp --enable-utf8 --enable-pcre16 --enable-unicode-properties 
    • the OpenSSL by the command:
      $ ./Configure -DOPENSSL_NO_HEARTBEATS no-shared no-idea no-mdc2 no-rc5 no-zlib enable-tlsext no-ssl2 no-ssl3 os/compiler:arm-linux-androideabi-
      $ make depend; make 
  • Call and compile OpenSCADA configuration by the command:
    $ ./configure --host=arm-linux-androideabi --prefix=/data/data/org.oscada --bindir=/data/data/org.oscada/bin --sysconfdir=/data/data/org.oscada --datarootdir=/data/data/org.oscada CoreLibNmToDlOpen=liboscada.so --disable-CoreLibVersion --disable-AllModuls --enable-SQLite=incl --enable-DBF=incl --enable-Sockets=incl --enable-Serial=incl --enable-SSL --enable-SelfSystem=incl --enable-UserProtocol=incl --enable-HTTP=incl --enable-JavaLikeCalc=incl --enable-LogicLev=incl --enable-BlockCalc=incl --enable-System --enable-OPC_UA --enable-DAQGate=incl --enable-ModBus=incl --enable-DCON=incl --enable-FSArch=incl --enable-DBArch=incl --enable-VCAEngine --enable-WebCfg --enable-WebCfgD --enable-WebVision --enable-WebUser --enable-FLibSYS=incl --enable-SystemTests --enable-FLibMath --enable-FLibComplex1 --with-qt5=yes --enable-QtMainThrd --enable-QTStarter --enable-QTCfg --enable-Vision 
  • Copy files "openscada", "liboscada.so.3", "libcrystax.so", "spec_SystemTests.so", "oscada.xml", "icons/*.png" to "/data/data/openscada/".
  • Start:
    $ LD_PRELOAD=./libcrystax.so LD_LIBRARY_PATH="./:${LD_LIBRARY_PATH}" ./openscada --config=./oscada.xml 

Current compiling and adapting status of the OpenSCADA core, it parts and the dependent libraries condensed and placed to the next table:

Part

Compiling
standalone executable
Qt5 and JNI CrystaxNDKr10
Original NDK r13 ABI21
(Builtin for modules)

Tests Commentaries and problems
The dependent libraries
PCRE, for the core OK OK OK Configuring command:
$ ./configure --host=arm-linux-androideabi --disable-cpp --enable-utf8 --enable-pcre16 --enable-unicode-properties 
OpenSSL, for: Transport.SSL, DAQ.OPC_UA, Special.FLibSYS (opt) OK OK OK Configuring command:
$ ./Configure -DOPENSSL_NO_HEARTBEATS no-shared no-idea no-mdc2 no-rc5 no-zlib enable-tlsext no-ssl2 no-ssl3 os/compiler:arm-linux-androideabi- ${CFLAGS} ${LDFLAGS}
$ make depend; make 
LibGD, for: the core (opt), UI.WebCfgD (opt), UI.WebVision OK OK OK Dependent from: libpng, jpeg, freetype, fontconfig

Also has links to macro __GNUC_PREREQ which missed on Android => a workaround placed to "features.h":

#ifndef __GNUC_PREREQ
# define __GNUC_PREREQ(maj, min) 1
#endif 

Configuring command:

$ ./configure --host=arm-linux-androideabi --prefix=/usr --sysconfdir=/etc --without-vpx --without-tiff --without-xpm 
-> libpng OK OK OK A version of "libpng" used from CrystaX and built for Original NDK r13 by a configuring command:
$ ./configure --host=arm-linux-androideabi --without-libpng-compat 
-> jpeg OK OK OK A version of "libjpg" used from CrystaX. and built for Original NDK r13 by a configuring command:
$ ./configure --host=arm-linux-androideabi 
--> expat OK OK OK Configuring command:
$ ./configure --host=arm-linux-androideabi 
--> freetype OK OK OK Configuring command:
$ LIBPNG_LDFLAGS="-I/home/roman/Android/Ndk/sources/libpng/include/libpng16" LIBPNG_LDFLAGS="-L/home/roman/Android/Ndk/sources/libpng/libs/armeabi-v7a -lpng -lm -lz" ./configure --host=arm-linux-androideabi --without-bzip2 --disable-shared 
-> fontconfig OK OK OK Configure for proper folders of the fonts. Configuring command:
$ ./configure --host=arm-linux-androideabi --disable-docs --with-cache-dir=/cache/fontconfig --with-default-fonts=/system/fonts 
libfftw3, for UI.{Vision,WebVision} (opt), Special.FLibSYS (opt) OK OK OK Configuring command:
$ ./configure --host=arm-linux-androideabi 
libiconv, for the core (opt) OK OK OK Successful built and used an external library. Configuring command:
$ ./configure --host=arm-linux-androideabi --enable-static 

Builtin one into CrystaX wrong and unfinished.

libintl (gettext), for the core (opt) OK OK OK configure.ac fixed to check symbol libintl_bindtextdomain into the library "libintl" and the symbol "libiconv_open" into the library "libiconv" checking before.

Successful built and used the external "libiconv".
Needed for "iconv" implementation but into CrystaX it is broken:
CRYSTAX_PANI: issetugid() not implemented!!!
Configuring command:

$ ./configure --host=arm-linux-androideabi --disable-java --disable-native-java --disable-largefile --enable-threads=posix --disable-rpath --disable-c++ --disable-libasprintf --disable-acl --disable-openmp --disable-curses 
libcrypt (GlibC), for the core (opt)  ?
libQt5, for UI.{QTStarter,QTCfg,Vision} OK OK OK Too specific for configuration and have some building's bugs, then it has fixed and adapted to architecture "armeabi-v7a-hard", for details see here. Due the problems with armeabi-v7a-hard the building was fully switched to armeabi-v7a but with parameters "-march=armv7-a -mfloat-abi=softfp -mfpu=vfp"!

Configuring command (hard-float):

$ ./configure -prefix /home/roman/Android/Ndk/sources/qt5 -recheck-all -opensource -confirm-license -xplatform android-g++ -nomake tests -nomake examples -android-ndk /home/roman/Android/Ndk -android-sdk /home/roman/Android/Sdk -android-ndk-host linux-x86_64 -android-toolchain-version 5 -android-ndk-platform android-19 -android-arch armeabi-v7a-hard -skip qttranslations -skip qtwebkit -skip qtserialport -skip qtwebkit-examples -no-warnings-are-errors -system-libjpeg -system-libpng -system-freetype -fontconfig 

Most the patched problems of building Qt5 has for Crystax NDK r10 and has not for Original NDK r13. Also Qt5 has significant problems of look (font's size and images show) at it building for hard-float! See details into [#h1233-4 the proper section].
Configuring command (soft-float):

$ ./configure -prefix /home/roman/Android/Ndk/sources/qt5 -recheck-all -opensource -confirm-license -xplatform android-g++ -nomake tests -nomake examples -android-ndk /home/roman/Android/Ndk -android-sdk /home/roman/Android/Sdk -android-ndk-host linux-x86_64 -android-toolchain-version 5 -android-ndk-platform android-19 -android-arch armeabi-v7a -skip qttranslations -skip qtwebkit -skip qtserialport -skip qtwebkit-examples -no-warnings-are-errors 
OpenSCADA
Generic and the core library OK OK OK
  • Test for some different for C(EN) locale => [../Using/PLC#h1088-14 successful for uk_UA.UTF-8].
  • Move the project AGLKS files to the device and try it from UI.WebVision.
  • Build mostly modules of OpenSCADA as separated "SO" and move them to a different folder.
  • Move all files of OpenSCADA to a separated folder. Prepare an environment to open external modules of OpenSCADA on an example of the module Special.SystemTests.
  • Performance tests executing for different options of the compiler.
  • Make the performance tests without "-mthumb".
  • Mostly modules included/builtin to the OpenSCADA core library.
  • The "pthread" library checking added by a macro AX_PTHREAD.
  • Core libraries moved from direct pointing to checking, for: -lm, -ldl, -lcrypt, -lz, -lpcre.
  • Some conditional definitions added for the program code:
    • ResAlloc: Check and define "__GLIBC_PREREQ" but into Android the LibC implementation Bionic; pthread_condattr_setclock() disabled for Android;
    • SYS: Needed parts moved from ieee754.h to the same file.
    • SYS: Multi CPU management and pthread_attr_setinheritsched() disabled for Android.
    • Mess: Messages encoding disabled for charset "US-ASCII", it's default one on Android.
    • Security: libcrypt checking expanded for crypt.h and to locked using for the function crypt().
    • Schedule: The core library name points straight into dlopen() for included/builtin modules but Bionic is wrong for the typical "NULL" into GLibC, by the definition "CoreLibNmToDlOpen".
DB.SQLite OK OK OK
  • Execute the DB tests.
  • Configure to store configuration here.
A version of "libpng" used from CrystaX and built for Original NDK r13 by a configuring command for version 3.8.7.1:
$ ./configure --host=arm-linux-androideabi --enable-threadsafe --disable-amalgamation --enable-load-extension --disable-tcl --enable-static 
DB.DBF OK OK OK Execute the DB tests.
DAQ.JavaLikeCalc OK OK OK Performance tests.
DAQ.LogicLev OK OK OK -
DAQ.BlockCalc OK OK OK -
DAQ.DAQGate OK OK OK -
DAQ.System OK OK OK (as a module) Create an automatic controller object and see for what sources are allowed. Allowed types of sensors: "CPU", "Net statistic", "Memory", "HDD statistic", "Up time".
DAQ.ModBus OK OK OK -
DAQ.DCON OK OK OK -
DAQ.OPC_UA OK OK OK (as a module) Create an input transport, an endpoint and connect remotely to it. Adapted to include/builtin into the OpenSCADA core.
Archive.FSArch OK OK OK -
Archive.DBArch OK OK OK -
Transport.Sockets OK OK OK Configure an input transport to remote connect to it. The function getservbyname_r() switched to getservbyname() for Android.
Transport.Serial OK OK OK (as a module) - Checking for linux/serial.h added and for linux/i2c-dev.h fixed.
Transport.SSL OK OK OK Configure an input transport to remote connect to it.
  • "/tmp" folder missed then we must use some other here but tmpnam() uses itself => switched to a local file for Android.
  • The function getservbyname_r() switched to getservbyname() for Android.
Protocol.SelfSystem OK OK OK Remote connect to it. The dependence to "libcrypto" of OpenSSL moved to be optional.
Protocol.UserProtocol OK OK OK -
Protocol.HTTP OK OK OK -
UI.VCAEngine OK OK OK (as a module)
UI.QTStarter OK OK OK (as a module) Adapt to start up from JNI.
UI.QTCfg OK OK OK (as a module)
UI.Vision OK OK OK (as a module)
UI.WebCfg OK OK OK (as a module)
UI.WebCfgD OK OK OK (as a module) Move the images to the OpenSCADA folder and try its and the module. A strong dependence from GD removed.
UI.WebVision OK OK OK (as a module) The library LibGD test on a trend of the primitive "Diagram" and a widget of the primitive "ElFigure" of the project AGLKS. Dependence to LibGD expanded by: -lpng -ljpeg -lfontconfig -lexpat -lfreetype
UI.WebUser OK OK OK (as a module)
Special.FLibSYS OK OK OK - Conditional test and using to SSL, for md5().
Special.SystemTests OK OK OK (as a module)
Special.FLibMath OK OK OK (as a module) Performance tests.
Special.FLibComplex1 OK OK OK (as a module)

In process of adaptation OpenSCADA to work on Android there was performed the significant approaches into the "autotool" based build environment OpenSCADA which can help further for adaption to work on other software platforms:

  • Generic cleaning.
  • Common adaption for static linking with the dependent libraries.
  • The "pthread" library checking by a macro AX_PTHREAD but it's too different on the like kind software environments.
  • Core libraries moved from direct pointing to checking, for: -lm, -ldl, -lcrypt, -lz, -lpcre. Which allow to pass libraries implemented into other system libraries and disable it at all in the correct way.

3 Qt5

Qt5 is cross-platform GUI toolkit and framework which historically used into OpenSCADA only as a GUI toolkit into Qt-based modules. Qt5 is a complex one and it has different problems on different versions and building options. For build examples of Qt5 next procedure was used.

$ /home/roman/Android/Ndk/sources/qt5/bin/qmake
$ make
$ make install INSTALL_ROOT=/home/roman/Android/Projects/icons
$ /home/roman/Android/Ndk/sources/qt5/bin/androiddeployqt --output /home/roman/Android/Projects/icons
$ ant clean; ant debug

Followed table represents problems of different version of Qt5 represented on an example "icons":

Version Options Problems
5.7 soft-float Equal to versions 5.8 and 5.9 but have problems at installing where it tries install to "/var".
5.8 GCC 5 Font is normal into bookmarks of the file dialog. May be it is generic problem into 5.7 5.8, (GCC 4.9), 5.9.
5.7, 5.8, 5.9 hard-float All Qt icons miss or too small.
5.9 CrystaX NDK r10, GCC 5 Build error by StdLib C++ some difference:
src/mbgl/util/http_header.cpp: In function 'mbgl::optional<std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long long int> > > mbgl::http::parseRetryHeaders(mbgl::optional<std::__cxx11::basic_string<char> >&, mbgl::optional<std::__cxx11::basic_string<char> >&)':
src/mbgl/util/http_header.cpp:38:67: error: call of overloaded 'stoi(const std::__cxx11::basic_string<char>&)' is ambiguous
             auto secs = std::chrono::seconds(std::stoi(*retryAfter));

4 Appending A. Extended performance tests on Asus Nexus7 II (Qualcomm Snapdragon APQ8064-1AA, Cortex-A15, 1.5 GHz, 4 Cores)

Test Operation sin(Pi), us , into JavaLikeCalc Operation pow(Pi,2), us , into JavaLikeCalc liboscada.so, MiB
armv5te, Soft, VFP2 0.9 1.58 0.15 0.88 13.79
armv5te, Soft, NEON 0.87 1.65 0.14 0.95 13.79
armv5te, Soft, NEON, Thumb 0.88 1.5 0.14 0.9 13
armv7-a, Soft, VFP 0.161 0.803 0.126 0.838 5.9
armv7-a, Hard, VFP2 0.162 0.776 0.138 0.844 13.85
armv7-a, Hard, NEON 0.168 0.793 0.123 0.854 13.85
armv7-a, Hard, NEON, Thumb 0.17 0.85 0.15 0.87 12.82

5 Appending B. List of the generic progress of the task

+ purchase a modern internet tablet with Android;
+ read a book about Android NDK, using of Android NDK and Crystalx-NDK;
+ compiling for tests, education and execution;
+ initially (minimum) build and execute OpenSCADA for console (without GUI): PCRE, OpenSCADA Core, builtin modules: Transport.Sockets, Protocol.SelfSystem, DAQ.JavaLikeCalc, Special.FLibMath;
+ make the performance tests for Soft and Hard float;
+ compile for all OpenSCADA key modules to include/builtin them into the core;
+ compile for needed external libraries: OpenSSL, SQLite, GD [expat,libpng,jpeg,fontconfig,freetype], intl, iconv;
+ rebuild all already built parts into the original Ndk (outward the standalone one);
+ build Qt5: in the default configuration, with the early built libraries;
+ initial build OpenSCADA with Qt5;
+ build and observe an example of Qt5 as a Java package (APK);
+ adapt OpenSCADA to Qt5 on Android and build as a Java package (APK); get the program's locale from Java environment and set it to environment LANG;
+ the Java package (APK) resolve for different data files placing and fill in by: OpenSCADA icon and main images, configuration files, files of translation of the interface, files of DB and other of the libraries and models;
+ OpenSCADA main functions related to Qt restore and fix: Qt5 builds with soft-float but hard-float causes the mostly problems; two branches were created, based on CrystaX NDK r10 (from ABI 19) and Original Ndk r13 (from ABI 21); default interface style was set to "fusion";
- Some Android specific expandings of the project OpenSCADA:
  • update Asus Nexux7 to Android 5 or more and check for the build on original NDKr13 and for ABI 21 and more.
  • work out for possibility of deploy in separated packages: "core" (with all binaries, data and means for user's projects creation); "pre-installed" projects and models (with the project or model data and using all libraries and data from the "core" package);
  • make some redesign for main page of UI.QTStarter but the tittle image is too small for big resolutions of screens;
  • expand the module UI.QTStarter for the OpenSCADA projects management function;
  • add for using QtWebView for last Qt5 and at QtWebKit miss.
  • expand for the module [../Doc/System DAQ.System] by the Android sensors.