dnp3 / rpi-dnp3-gpio

Example project that interfaces opendnp3 with the Raspberry PI's GPIO pins
Apache License 2.0
11 stars 8 forks source link

rpi-dnp3-gpio 2.1.0 release linking error #2

Closed geyseran closed 7 years ago

geyseran commented 7 years ago

pi@raspberrypi:~/rpi-dnp3-gpio/build $ make Scanning dependencies of target rpi-dnp3-gpio [ 20%] Building C object CMakeFiles/rpi-dnp3-gpio.dir/deps/inih/ini.c.o [ 40%] Building CXX object CMakeFiles/rpi-dnp3-gpio.dir/src/Config.cpp.o [ 60%] Building CXX object CMakeFiles/rpi-dnp3-gpio.dir/src/main.cpp.o [ 80%] Building CXX object CMakeFiles/rpi-dnp3-gpio.dir/src/GPIOCommandHandler.cpp.o [100%] Linking CXX executable rpi-dnp3-gpio /usr/bin/ld: CMakeFiles/rpi-dnp3-gpio.dir/src/main.cpp.o: undefined reference to symbol '_ZN8opendnp36BinaryC1EbhN7openpal10UInt48TypeE' /usr/local/lib/libopendnp3.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/rpi-dnp3-gpio.dir/build.make:172: recipe for target 'rpi-dnp3-gpio' failed make[2]: * [rpi-dnp3-gpio] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/rpi-dnp3-gpio.dir/all' failed make[1]: * [CMakeFiles/rpi-dnp3-gpio.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *\ [all] Error 2 pi@raspberrypi:~/rpi-dnp3-gpio/build $

jadamcrain commented 7 years ago

Can you run make VERBOSE=1?

This error is a linking error in that a symbol from the openpal library is not being found...

Where are the opendnp3 libraries installed on your system?

geyseran commented 7 years ago

I am trying to use the raspberry pi as a tiny dnp3 outstation that I can connect to a large scada system to test dnp3 over tcp ip socket communications. would this build work for this purpose? Here are the library location and verbose output: pi@raspberrypi:/usr/local/include$ ls -ltr

drwxr-xr-x 3 root staff 4096 Jul 17 16:29 asiodnp3 drwxr-xr-x 7 root staff 4096 Jul 17 16:29 opendnp3 drwxr-xr-x 2 root staff 4096 Jul 17 16:29 dnp3decode drwxr-xr-x 8 root staff 4096 Jul 17 16:29 openpal drwxr-xr-x 3 root staff 4096 Jul 17 16:29 asiopal drwxr-xr-x 4 root staff 4096 Jul 20 21:24 hammer pi@raspberrypi:/usr/local/include$

pi@raspberrypi:~/rpi-dnp3-gpio/build$ more build_verbose_errors pi@raspberrypi:~/rpi-dnp3-gpio/build$ make VERBOSE=1 /usr/local/bin/cmake -H/home/pi/rpi-dnp3-gpio -B/home/pi/rpi-dnp3-gpio/build --check-build-system CMakeFiles/Makefile.cmake 0 /usr/local/bin/cmake -E cmake_progress_start /home/pi/rpi-dnp3-gpio/build/CMakeFiles /home/pi/rpi-dnp3-gpio/build/CMakeFiles/progre ss.marks make -f CMakeFiles/Makefile2 all make[1]: Entering directory '/home/pi/rpi-dnp3-gpio/build' make -f CMakeFiles/rpi-dnp3-gpio.dir/build.make CMakeFiles/rpi-dnp3-gpio.dir/depend make[2]: Entering directory '/home/pi/rpi-dnp3-gpio/build' cd /home/pi/rpi-dnp3-gpio/build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/rpi-dnp3-gpio /home/pi/rpi-dnp3- gpio /home/pi/rpi-dnp3-gpio/build /home/pi/rpi-dnp3-gpio/build /home/pi/rpi-dnp3-gpio/build/CMakeFiles/rpi-dnp3-gpio.dir/DependInfo .cmake --color= Dependee "/home/pi/rpi-dnp3-gpio/build/CMakeFiles/rpi-dnp3-gpio.dir/DependInfo.cmake" is newer than depender "/home/pi/rpi-dnp3-gpi o/build/CMakeFiles/rpi-dnp3-gpio.dir/depend.internal". Dependee "/home/pi/rpi-dnp3-gpio/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/pi/rpi-dnp3-gpio/b uild/CMakeFiles/rpi-dnp3-gpio.dir/depend.internal". Scanning dependencies of target rpi-dnp3-gpio make[2]: Leaving directory '/home/pi/rpi-dnp3-gpio/build' make -f CMakeFiles/rpi-dnp3-gpio.dir/build.make CMakeFiles/rpi-dnp3-gpio.dir/build make[2]: Entering directory '/home/pi/rpi-dnp3-gpio/build' [ 20%] Building C object CMakeFiles/rpi-dnp3-gpio.dir/deps/inih/ini.c.o /usr/bin/cc -I/home/pi/rpi-dnp3-gpio/deps/inih -o CMakeFiles/rpi-dnp3-gpio.dir/deps/inih/ini.c.o -c /home/pi/rpi-dnp3-gpio/de ps/inih/ini.c [ 40%] Building CXX object CMakeFiles/rpi-dnp3-gpio.dir/src/Config.cpp.o /usr/bin/c++ -I/home/pi/rpi-dnp3-gpio/deps/inih -Wall -std=c++11 -o CMakeFiles/rpi-dnp3-gpio.dir/src/Config.cpp.o -c /home/pi /rpi-dnp3-gpio/src/Config.cpp [ 60%] Building CXX object CMakeFiles/rpi-dnp3-gpio.dir/src/main.cpp.o /usr/bin/c++ -I/home/pi/rpi-dnp3-gpio/deps/inih -Wall -std=c++11 -o CMakeFiles/rpi-dnp3-gpio.dir/src/main.cpp.o -c /home/pi/r pi-dnp3-gpio/src/main.cpp [ 80%] Building CXX object CMakeFiles/rpi-dnp3-gpio.dir/src/GPIOCommandHandler.cpp.o /usr/bin/c++ -I/home/pi/rpi-dnp3-gpio/deps/inih -Wall -std=c++11 -o CMakeFiles/rpi-dnp3-gpio.dir/src/GPIOCommandHandler.cpp.o -c /home/pi/rpi-dnp3-gpio/src/GPIOCommandHandler.cpp [100%] Linking CXX executable rpi-dnp3-gpio /usr/local/bin/cmake -E cmake_link_script CMakeFiles/rpi-dnp3-gpio.dir/link.txt --verbose=1 /usr/bin/c++ -Wall -std=c++11 CMakeFiles/rpi-dnp3-gpio.dir/deps/inih/ini.c.o CMakeFiles/rpi-dnp3-gpio.dir/src/Config.cpp.o CMak eFiles/rpi-dnp3-gpio.dir/src/main.cpp.o CMakeFiles/rpi-dnp3-gpio.dir/src/GPIOCommandHandler.cpp.o -o rpi-dnp3-gpio -rdynamic -lwir ingPi -lasiodnp3 -lasiopal -lopendnp3 -lopenpal -lpthread /usr/bin/ld: CMakeFiles/rpi-dnp3-gpio.dir/src/main.cpp.o: undefined reference to symbol '_ZN8opendnp36BinaryC1EbhN7openpal10UInt48T ypeE' //usr/local/lib/libopendnp3.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/rpi-dnp3-gpio.dir/build.make:172: recipe for target 'rpi-dnp3-gpio' failed make[2]: * [rpi-dnp3-gpio] Error 1 make[2]: Leaving directory '/home/pi/rpi-dnp3-gpio/build' CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/rpi-dnp3-gpio.dir/all' failed make[1]: * [CMakeFiles/rpi-dnp3-gpio.dir/all] Error 2 make[1]: Leaving directory '/home/pi/rpi-dnp3-gpio/build' Makefile:83: recipe for target 'all' failed make: *\ [all] Error 2 pi@raspberrypi:~/rpi-dnp3-gpio/build$

jadamcrain commented 7 years ago

Yes, this will work nicely for that purpose. It was designed specifcally for the Cybati mini kits:

https://cybati.org/cybatiworks-one

But you could wire anything to the associated GPIO pins.

normally, headers/libraries are installed in /usr/include and /usr/lib on Debian distributions, so here's what I want you to try.

1) Remove the existing libraries and headers from /usr/local/include and /usr/local/lib. 2) Rebuild the opendnp3 from scratch using CMAKE -DFULL=ON -DCMAKE_INSTALL_PREFIX=/usr

This will ensure that the libraries and headers go to the right locations.

-Adam

geyseran commented 7 years ago

I have been trying to automate the opendnp3 installation with 2 scripts, see attached document. I am going to use this on a fresh debian wheezy image. Would you be so kind as to look at the scripts and advise me if I am missing something. Much appreciated. -Andre

opendnp3.docx

jadamcrain commented 7 years ago

Hi Andre,

This looks correct except for the fact that you don't need pesco/hammer at all. It's an unrelated library and isn't needed for opendnp3 or the rpi project.

So the full dependency tree would be:

-Adam

jadamcrain commented 7 years ago

FYI, I just commited a change that allows you to automatically checkout out ASIO as a submodule using:

git clone --recursive https://github.com/automatak/dnp3.git

No separate steps for downloading ASIO or setting environment variables would be required:

https://groups.google.com/forum/#!topic/automatak-dnp3/CtkGyfqWyMQ

geyseran commented 7 years ago

I want to make sure that all stages are built without errors. I have installed the wiringPi and then moved to the new dnp3 link you supplied. When I run the cmake I get the following errors: pi@raspberrypi:~/dnp3/build $ cmake .. -DFULL=ON -DCMAKE_INSTALL_PREFIX=/usr -- The C compiler identification is GNU 4.9.2 -- The CXX compiler identification is GNU 4.9.2 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Looking for pthread_timedjoin_np in pthread -- Looking for pthread_timedjoin_np in pthread - found ASIO has been checked out as a git submodule: /home/pi/dnp3/deps/asio/asio/include CMake Error at /usr/local/share/cmake-3.4/Modules/FindPackageHandleStandardArgs.cmake:148 (message): Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR) Call Stack (most recent call first): /usr/local/share/cmake-3.4/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE) /usr/local/share/cmake-3.4/Modules/FindOpenSSL.cmake:367 (find_package_handle_standard_args) CMakeLists.txt:56 (find_package)

-- Configuring incomplete, errors occurred! See also "/home/pi/dnp3/build/CMakeFiles/CMakeOutput.log". See also "/home/pi/dnp3/build/CMakeFiles/CMakeError.log". pi@raspberrypi:~/dnp3/build $

What is still misssing? -Andre

jadamcrain commented 7 years ago

Try:

sudo apt-get install libssl1.0.0

I believe it can't find openssl.

geyseran commented 7 years ago

I managed to overcome the problem by installing sudo apt-get install libssl-dev. I am busy making all the files. Currently at 76% without any problems. When it is installed, do I still need to install git clone --recursive https://github.com/automatak/rpi-dnp3-gpio.git? How to I run it as an outstation?

jadamcrain commented 7 years ago

Great.

Yes, you still need to recursively clone rpi-dnp3-gpio so that it can inih library automatically for you.

This executable only runs as an outstation:

./rpi-dnp3-gpio default.ini

You can edit the default INI file to change IO mappings and a few parameters.

geyseran commented 7 years ago

Must I use any special cmake commands with rpi-dnp3-gpio?

jadamcrain commented 7 years ago

no

geyseran commented 7 years ago

I am seeing the following: pi@raspberrypi:~/rpi-dnp3-gpio/build $ sudo ./rpi-dnp3-gpio ../default.ini pin 25 set as INPUT pin 24 set as INPUT pin 23 set as INPUT pin 18 set as INPUT pin 22 set as OUTPUT pin 5 set as OUTPUT pin 6 set as OUTPUT pin 27 set as OUTPUT pin 17 set as OUTPUT pin 21 set as OUTPUT pin 12 set as OUTPUT pin 16 set as OUTPUT pin 20 set as OUTPUT pin 13 set as OUTPUT pin 19 set as OUTPUT pin 26 set as OUTPUT Sample period is: 50

jadamcrain commented 7 years ago

Great. It's running.

geyseran commented 7 years ago

Thanks for the help. Now to try and test it against a master station?

jadamcrain commented 7 years ago

Yup, connect a master to it on port 20000.

geyseran commented 7 years ago

Is there a way that one can toggle a gpio pin to simulate a change of state on the outstation? (with software) I do not have any hardware connected to the gpio pins at the moment?

jadamcrain commented 7 years ago

I'm not sure if there is a software way to emulate this. I developed this against an I/O board that connects to the GPIO header.

jadamcrain commented 7 years ago

If you want to way to change values, etc, w/o using any hardware just use example outstation from the opendnp3 build.