mirror of
https://github.com/thiagoralves/OpenPLC_v3.git
synced 2026-02-06 10:23:51 +08:00
ethercat install options added
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,3 +16,4 @@ webserver/bin
|
||||
webserver/build
|
||||
obj/
|
||||
utils/dnp3_src/CMakeFiles/
|
||||
webserver/scripts/ethercat
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
ETHERCAT_INSTALL=""
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo ""
|
||||
echo "Error: You must provide a platform name as argument"
|
||||
@@ -98,16 +101,18 @@ function install_all_libs {
|
||||
fi
|
||||
cd ../..
|
||||
|
||||
echo ""
|
||||
echo "[EtherCAT]"
|
||||
cd utils/ethercat_src
|
||||
./install.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error compiling EtherCAT"
|
||||
echo "OpenPLC was NOT installed!"
|
||||
exit 1
|
||||
if [ "$ETHERCAT_INSTALL" == "install" ]; then
|
||||
echo ""
|
||||
echo "[EtherCAT]"
|
||||
cd utils/ethercat_src
|
||||
./install.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error compiling EtherCAT"
|
||||
echo "OpenPLC was NOT installed!"
|
||||
exit 1
|
||||
fi
|
||||
cd ../..
|
||||
fi
|
||||
cd ../..
|
||||
|
||||
echo ""
|
||||
echo "[OPEN DNP3]"
|
||||
@@ -171,7 +176,6 @@ WantedBy=multi-user.target" >> openplc.service
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
if [ "$1" == "win" ]; then
|
||||
echo "Installing OpenPLC on Windows"
|
||||
cp ./utils/apt-cyg/apt-cyg ./
|
||||
@@ -273,7 +277,15 @@ if [ "$1" == "win" ]; then
|
||||
|
||||
|
||||
elif [ "$1" == "linux" ]; then
|
||||
|
||||
echo "Installing OpenPLC on Linux"
|
||||
if [ "$2" == "ethercat" ]; then
|
||||
echo "including EtherCAT"
|
||||
ETHERCAT_INSTALL="install"
|
||||
echo ethercat > webserver/scripts/ethercat
|
||||
else
|
||||
echo "" > webserver/scripts/ethercat
|
||||
fi
|
||||
linux_install_deps sudo
|
||||
|
||||
install_py_deps
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
./background_installer.sh $1 2>&1 | tee install_log.txt
|
||||
./background_installer.sh $1 $2 2>&1 | tee install_log.txt
|
||||
|
||||
@@ -32,7 +32,9 @@
|
||||
|
||||
#include "iec_types.h"
|
||||
#include "ladder.h"
|
||||
#ifdef _ethercat_src
|
||||
#include "ethercat_src.h"
|
||||
#endif
|
||||
|
||||
#define OPLC_CYCLE 50000000
|
||||
|
||||
@@ -219,8 +221,10 @@ int main(int argc,char **argv)
|
||||
//======================================================
|
||||
// HARDWARE INITIALIZATION
|
||||
//======================================================
|
||||
#ifdef _ethercat_src
|
||||
type_logger_callback logger = logger_callback;
|
||||
ethercat_configure("../utils/ethercat_src/build/ethercat.cfg", logger);
|
||||
#endif
|
||||
initializeHardware();
|
||||
initializeMB();
|
||||
initCustomLayer();
|
||||
@@ -275,18 +279,21 @@ int main(int argc,char **argv)
|
||||
//attached to the user variables
|
||||
glueVars();
|
||||
|
||||
#ifdef _ethercat_src
|
||||
boolvar_call_back bool_input_callback = bool_input_call_back;
|
||||
boolvar_call_back bool_output_callback = bool_output_call_back;
|
||||
int8var_call_back byte_input_callback = byte_input_call_back;
|
||||
int8var_call_back byte_output_callback = byte_output_call_back;
|
||||
int16var_call_back int_input_callback = int_input_call_back;
|
||||
int16var_call_back int_output_callback = int_output_call_back;
|
||||
#endif
|
||||
|
||||
updateBuffersIn(); //read input image
|
||||
|
||||
pthread_mutex_lock(&bufferLock); //lock mutex
|
||||
|
||||
|
||||
#ifdef _ethercat_src
|
||||
if(ethercat_callcyclic(BUFFER_SIZE,
|
||||
bool_input_callback,
|
||||
bool_output_callback,
|
||||
@@ -297,6 +304,7 @@ int main(int argc,char **argv)
|
||||
printf("EtherCAT cyclic failed\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
updateCustomIn();
|
||||
updateBuffersIn_MB(); //update input image table with data from slave devices
|
||||
handleSpecialFunctions();
|
||||
@@ -316,7 +324,9 @@ int main(int argc,char **argv)
|
||||
// SHUTTING DOWN OPENPLC RUNTIME
|
||||
//======================================================
|
||||
pthread_join(interactive_thread, NULL);
|
||||
#ifdef _ethercat_src
|
||||
ethercat_terminate_src();
|
||||
#endif
|
||||
printf("Disabling outputs\n");
|
||||
disableOutputs();
|
||||
updateCustomOut();
|
||||
|
||||
@@ -8,6 +8,7 @@ fi
|
||||
cd scripts &>/dev/null
|
||||
|
||||
OPENPLC_PLATFORM=$(cat openplc_platform)
|
||||
ETHERCAT_OPT=$(cat ethercat)
|
||||
|
||||
#store the active program filename
|
||||
echo "$1" > ../active_program
|
||||
@@ -23,8 +24,12 @@ if [ $? -ne 0 ]; then
|
||||
echo "Compilation finished with errors!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# stick reference to ethercat_src in there for CoE access etc functionality that needs to be accessed from PLC
|
||||
sed -i '7s/^/#include "ethercat_src.h" /' Res0.c
|
||||
if [ "$ETHERCAT_OPT" = "ethercat" ]; then
|
||||
sed -i '7s/^/#include "ethercat_src.h" /' Res0.c
|
||||
fi
|
||||
|
||||
echo "Moving Files..."
|
||||
mv -f POUS.c POUS.h LOCATED_VARIABLES.h VARIABLES.csv Config0.c Config0.h Res0.c ./core/
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -33,6 +38,13 @@ if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$ETHERCAT_OPT" = "ethercat" ]; then
|
||||
echo "Including EtherCAT"
|
||||
ETHERCAT_INC="-L../../utils/ethercat_src/build/lib -lethercat_src -I../../utils/ethercat_src/src -D _ethercat_src"
|
||||
else
|
||||
ETHERCAT_INC=""
|
||||
fi
|
||||
|
||||
#compiling for each platform
|
||||
cd core
|
||||
if [ "$OPENPLC_PLATFORM" = "win" ]; then
|
||||
@@ -71,7 +83,7 @@ elif [ "$OPENPLC_PLATFORM" = "linux" ]; then
|
||||
echo "Compilation finished with errors!"
|
||||
exit 1
|
||||
fi
|
||||
g++ -std=gnu++11 -I ./lib -c Res0.c -lasiodnp3 -lasiopal -lopendnp3 -lopenpal -w -L../../utils/ethercat_src/build/lib -lethercat_src -I../../utils/ethercat_src/src
|
||||
g++ -std=gnu++11 -I ./lib -c Res0.c -lasiodnp3 -lasiopal -lopendnp3 -lopenpal -w $ETHERCAT_INC
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error compiling C files"
|
||||
echo "Compilation finished with errors!"
|
||||
@@ -80,7 +92,7 @@ elif [ "$OPENPLC_PLATFORM" = "linux" ]; then
|
||||
echo "Generating glueVars..."
|
||||
./glue_generator
|
||||
echo "Compiling main program..."
|
||||
g++ -std=gnu++11 *.cpp *.o -o openplc -I ./lib -pthread -fpermissive `pkg-config --cflags --libs libmodbus` -lasiodnp3 -lasiopal -lopendnp3 -lopenpal -w -L../../utils/ethercat_src/build/lib -lethercat_src -I../../utils/ethercat_src/src
|
||||
g++ -std=gnu++11 *.cpp *.o -o openplc -I ./lib -pthread -fpermissive `pkg-config --cflags --libs libmodbus` -lasiodnp3 -lasiopal -lopendnp3 -lopenpal -w $ETHERCAT_INC
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error compiling C files"
|
||||
echo "Compilation finished with errors!"
|
||||
|
||||
Reference in New Issue
Block a user