mirror of
https://github.com/thiagoralves/OpenPLC_v2.git
synced 2025-05-09 00:21:11 +08:00
fixed merge conflicts
This commit is contained in:
commit
b348a98ad4
1
build.sh
1
build.sh
@ -44,6 +44,7 @@ select opt in $OPTIONS; do
|
||||
./autogen.sh
|
||||
./configure
|
||||
sudo make install
|
||||
sudo ldconfig
|
||||
echo [OPENPLC]
|
||||
cd ..
|
||||
./build_core.sh
|
||||
|
12
build_win.sh
12
build_win.sh
@ -30,10 +30,11 @@ select opt in $OPTIONS; do
|
||||
echo [OPENPLC]
|
||||
cd ..
|
||||
./build_core.sh
|
||||
echo 'export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"' >> ~/.bashrc
|
||||
exit
|
||||
elif [ "$opt" = "Modbus" ]; then
|
||||
cp ./hardware_layers/modbus_master.cpp ./hardware_layer.cpp
|
||||
cp ./core_builders/build_modbus.sh ../build_core.sh
|
||||
cp ./core_builders/build_modbus_win.sh ../build_core.sh
|
||||
echo [LIBMODBUS]
|
||||
cd ..
|
||||
cd libmodbus_src
|
||||
@ -43,6 +44,7 @@ select opt in $OPTIONS; do
|
||||
echo [OPENPLC]
|
||||
cd ..
|
||||
./build_core.sh
|
||||
echo 'export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"' >> ~/.bashrc
|
||||
exit
|
||||
elif [ "$opt" = "Fischertechnik" ]; then
|
||||
cp ./hardware_layers/fischertechnik.cpp ./hardware_layer.cpp
|
||||
@ -50,6 +52,7 @@ select opt in $OPTIONS; do
|
||||
echo [OPENPLC]
|
||||
cd ..
|
||||
./build_core.sh
|
||||
echo 'export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"' >> ~/.bashrc
|
||||
exit
|
||||
elif [ "$opt" = "RaspberryPi" ]; then
|
||||
cp ./hardware_layers/raspberrypi.cpp ./hardware_layer.cpp
|
||||
@ -57,6 +60,7 @@ select opt in $OPTIONS; do
|
||||
echo [OPENPLC]
|
||||
cd ..
|
||||
./build_core.sh
|
||||
echo 'export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"' >> ~/.bashrc
|
||||
exit
|
||||
elif [ "$opt" = "UniPi" ]; then
|
||||
cp ./hardware_layers/unipi.cpp ./hardware_layer.cpp
|
||||
@ -64,6 +68,7 @@ select opt in $OPTIONS; do
|
||||
echo [OPENPLC]
|
||||
cd ..
|
||||
./build_core.sh
|
||||
echo 'export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"' >> ~/.bashrc
|
||||
exit
|
||||
elif [ "$opt" = "PiXtend" ]; then
|
||||
cp ./hardware_layers/pixtend.cpp ./hardware_layer.cpp
|
||||
@ -71,6 +76,7 @@ select opt in $OPTIONS; do
|
||||
echo [OPENPLC]
|
||||
cd ..
|
||||
./build_core.sh
|
||||
echo 'export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"' >> ~/.bashrc
|
||||
exit
|
||||
elif [ "$opt" = "Arduino" ]; then
|
||||
cp ./hardware_layers/arduino.cpp ./hardware_layer.cpp
|
||||
@ -78,6 +84,7 @@ select opt in $OPTIONS; do
|
||||
echo [OPENPLC]
|
||||
cd ..
|
||||
./build_core.sh
|
||||
echo 'export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"' >> ~/.bashrc
|
||||
exit
|
||||
elif [ "$opt" = "ESP8266" ]; then
|
||||
cp ./hardware_layers/esp8266.cpp ./hardware_layer.cpp
|
||||
@ -85,6 +92,7 @@ select opt in $OPTIONS; do
|
||||
echo [OPENPLC]
|
||||
cd ..
|
||||
./build_core.sh
|
||||
echo 'export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"' >> ~/.bashrc
|
||||
exit
|
||||
elif [ "$opt" = "Arduino+RaspberryPi" ]; then
|
||||
cp ./hardware_layers/arduino.cpp ./hardware_layer.cpp
|
||||
@ -92,6 +100,7 @@ select opt in $OPTIONS; do
|
||||
echo [OPENPLC]
|
||||
cd ..
|
||||
./build_core.sh
|
||||
echo 'export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"' >> ~/.bashrc
|
||||
exit
|
||||
elif [ "$opt" = "Simulink" ]; then
|
||||
cp ./hardware_layers/simulink.cpp ./hardware_layer.cpp
|
||||
@ -99,6 +108,7 @@ select opt in $OPTIONS; do
|
||||
echo [OPENPLC]
|
||||
cd ..
|
||||
./build_core.sh
|
||||
echo 'export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"' >> ~/.bashrc
|
||||
exit
|
||||
else
|
||||
#clear
|
||||
|
@ -6,5 +6,5 @@ g++ -I ./lib -c Res0.c
|
||||
echo Generating glueVars.cpp
|
||||
./glue_generator
|
||||
echo Compiling main program
|
||||
g++ *.cpp *.o -o openplc -I ./lib -pthread -fpermissive -I /usr/local/include/modbus -L /usr/local/lib -lmodbus
|
||||
g++ *.cpp *.o -o openplc -I ./lib -pthread -fpermissive `pkg-config --cflags --libs libmodbus`
|
||||
cd ..
|
||||
|
10
core/core_builders/build_modbus_win.sh
Executable file
10
core/core_builders/build_modbus_win.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
cd core
|
||||
echo Generating object files...
|
||||
g++ -I ./lib -c Config0.c
|
||||
g++ -I ./lib -c Res0.c
|
||||
echo Generating glueVars.cpp
|
||||
./glue_generator
|
||||
echo Compiling main program
|
||||
g++ *.cpp *.o -o openplc -I ./lib -pthread -fpermissive -I /usr/local/include/modbus -L /usr/local/lib -lmodbus
|
||||
cd ..
|
@ -62,6 +62,7 @@ struct OPLC_input input_data;
|
||||
struct OPLC_output output_data;
|
||||
|
||||
int serial_fd;
|
||||
int isPortFound = 0;
|
||||
|
||||
pthread_mutex_t ioLock;
|
||||
|
||||
@ -279,14 +280,15 @@ bool receivePacket()
|
||||
{
|
||||
uint8_t receiveBuffer[100];
|
||||
int response = read(serial_fd, receiveBuffer, 100);
|
||||
if (response == -1)
|
||||
if (response == -1 && isPortFound)
|
||||
{
|
||||
printf("Couldn't read from IO. Error: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
else if (response == 0)
|
||||
{
|
||||
printf("No response from IO. Error: %s\n", strerror(errno));
|
||||
//avoid printing error messages just if the serial returned 0
|
||||
//printf("No response from IO. Error: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
@ -534,6 +536,7 @@ void initializeHardware()
|
||||
|
||||
if (portId != -1)
|
||||
{
|
||||
isPortFound = 1;
|
||||
serial_fd = serialport_init(portsList[portId], 115200);
|
||||
sleep_ms(2500);
|
||||
pthread_t thread;
|
||||
|
@ -69,6 +69,9 @@ extern IEC_LINT *lint_memory[BUFFER_SIZE];
|
||||
//lock for the buffer
|
||||
extern pthread_mutex_t bufferLock;
|
||||
|
||||
//Common task timer
|
||||
extern unsigned long long common_ticktime__;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//FUNCTION PROTOTYPES
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -114,6 +114,10 @@ int main(int argc,char **argv)
|
||||
int opt;
|
||||
opterr = 0;
|
||||
|
||||
//======================================================
|
||||
// READ COMMAND LINE ARGS
|
||||
//======================================================
|
||||
|
||||
while ((opt = getopt (argc, argv, "m:d:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'm':
|
||||
@ -219,6 +223,6 @@ int main(int argc,char **argv)
|
||||
updateBuffers();
|
||||
updateTime();
|
||||
|
||||
sleep_until(&timer_start, OPLC_CYCLE);
|
||||
sleep_until(&timer_start, common_ticktime__);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
int createSocket(int port)
|
||||
{
|
||||
int socket_fd;
|
||||
int reuse = 1;
|
||||
struct sockaddr_in server_addr;
|
||||
|
||||
//Create TCP Socket
|
||||
@ -52,6 +53,20 @@ int createSocket(int port)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&reuse, sizeof(reuse)) < 0)
|
||||
{
|
||||
perror("Server: setsockopt(SO_REUSEADDR) failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef SO_REUSEPORT
|
||||
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEPORT, (const char *)&reuse, sizeof(reuse)) < 0)
|
||||
{
|
||||
perror("Server: setsockopt(SO_REUSEPORT) failed");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
//Initialize Server Struct
|
||||
bzero((char *) &server_addr, sizeof(server_addr));
|
||||
server_addr.sin_family = AF_INET;
|
||||
@ -131,6 +146,8 @@ void *handleConnections(void *arguments)
|
||||
|
||||
processMessage(buffer, messageSize, client_fd);
|
||||
}
|
||||
|
||||
printf("Server: Closing thread for client ID: %d\n", client_fd);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -42,6 +42,7 @@ void generateHeader()
|
||||
#include \"iec_std_lib.h\"\r\n\
|
||||
\r\n\
|
||||
TIME __CURRENT_TIME;\r\n\
|
||||
extern unsigned long long common_ticktime__;\r\n\
|
||||
\r\n\
|
||||
//Internal buffers for I/O and memory. These buffers are defined in the\r\n\
|
||||
//auto-generated glueVars.cpp file\r\n\
|
||||
@ -216,7 +217,7 @@ void generateBottom()
|
||||
\r\n\
|
||||
void updateTime()\r\n\
|
||||
{\r\n\
|
||||
__CURRENT_TIME.tv_nsec += 50000000;\r\n\
|
||||
__CURRENT_TIME.tv_nsec += common_ticktime__;\r\n\
|
||||
\r\n\
|
||||
if (__CURRENT_TIME.tv_nsec >= 1000000000)\r\n\
|
||||
{\r\n\
|
||||
|
Loading…
x
Reference in New Issue
Block a user