From 4221665a593f4f01d9327e89e02590300a427033 Mon Sep 17 00:00:00 2001 From: Chrismettal Date: Tue, 19 Mar 2024 21:52:03 +0100 Subject: [PATCH] Revert "Pass Modbus RTS settings through new hardware layer settings struct" This reverts commit d38100eb9437f00e8c76376b7ba6b0d7dea3f36c. --- webserver/core/custom_layer.h | 2 -- webserver/core/custom_layer_options.h | 11 ----------- webserver/core/hardware_layers/PiPLC.cpp | 7 +++---- webserver/core/hardware_layers/blank.cpp | 2 +- webserver/core/hardware_layers/fischertechnik.cpp | 2 +- webserver/core/hardware_layers/neuron.cpp | 2 +- webserver/core/hardware_layers/pixtend.cpp | 2 +- webserver/core/hardware_layers/pixtend2l.cpp | 2 +- webserver/core/hardware_layers/pixtend2s.cpp | 2 +- webserver/core/hardware_layers/psm.cpp | 2 +- webserver/core/hardware_layers/raspberrypi.cpp | 2 +- webserver/core/hardware_layers/raspberrypi_old.cpp | 2 +- webserver/core/hardware_layers/sequent.cpp | 2 +- webserver/core/hardware_layers/simulink.cpp | 2 +- webserver/core/hardware_layers/sl_rp4.cpp | 2 +- webserver/core/hardware_layers/unipi.cpp | 2 +- webserver/core/ladder.h | 4 ++-- webserver/core/main.cpp | 8 ++------ webserver/core/modbus_master.cpp | 2 +- 19 files changed, 21 insertions(+), 39 deletions(-) delete mode 100755 webserver/core/custom_layer_options.h diff --git a/webserver/core/custom_layer.h b/webserver/core/custom_layer.h index 29ab503..fbbd8c8 100755 --- a/webserver/core/custom_layer.h +++ b/webserver/core/custom_layer.h @@ -6,8 +6,6 @@ // in here by clicking on the "Restore Original Code" button above. //----------------------------------------------------------------------------- -#include "custom_layer_options.h" - //----------------------------------------------------------------------------- // These are the ignored I/O vectors. If you want to override how OpenPLC // handles a particular input or output, you must put them in the ignored diff --git a/webserver/core/custom_layer_options.h b/webserver/core/custom_layer_options.h deleted file mode 100755 index ec04661..0000000 --- a/webserver/core/custom_layer_options.h +++ /dev/null @@ -1,11 +0,0 @@ -//----------------------------------------------------------------------------- -// DISCLAIMER: EDDITING THIS FILE CAN BREAK YOUR OPENPLC RUNTIME! IF YOU DON'T -// KNOW WHAT YOU'RE DOING, JUST DON'T DO IT. EDIT AT YOUR OWN RISK. -// -// PS: You can always restore original functionality if you broke something -// in here by clicking on the "Restore Original Code" button above. -//----------------------------------------------------------------------------- - -struct custom_layer_options { - uint8_t rpi_modbus_rts_pin; // If <> 0, expect hardware RTS to be used with this pin -}; diff --git a/webserver/core/hardware_layers/PiPLC.cpp b/webserver/core/hardware_layers/PiPLC.cpp index 384fb1f..530670e 100755 --- a/webserver/core/hardware_layers/PiPLC.cpp +++ b/webserver/core/hardware_layers/PiPLC.cpp @@ -78,7 +78,7 @@ int analogOutBufferPinMask[MAX_ANALOG_OUT] = { 18, 19 }; // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { gpioInitialise(); //piHiPri(99); @@ -109,11 +109,10 @@ void initializeHardware(custom_layer_options& customLayerOptions) } } - // Modbus - customLayerOptions.rpi_modbus_rts_pin = MODBUS_RTS; - // I²C? + // Modbus? + // 1-Wire? } diff --git a/webserver/core/hardware_layers/blank.cpp b/webserver/core/hardware_layers/blank.cpp index ce58cad..62b2a20 100755 --- a/webserver/core/hardware_layers/blank.cpp +++ b/webserver/core/hardware_layers/blank.cpp @@ -37,7 +37,7 @@ // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { } diff --git a/webserver/core/hardware_layers/fischertechnik.cpp b/webserver/core/hardware_layers/fischertechnik.cpp index 426ca7d..4b02783 100755 --- a/webserver/core/hardware_layers/fischertechnik.cpp +++ b/webserver/core/hardware_layers/fischertechnik.cpp @@ -45,7 +45,7 @@ int serialFd; //serial file descriptor // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { wiringPiSetup(); //piHiPri(99); diff --git a/webserver/core/hardware_layers/neuron.cpp b/webserver/core/hardware_layers/neuron.cpp index ed0a5a7..cabdbfe 100755 --- a/webserver/core/hardware_layers/neuron.cpp +++ b/webserver/core/hardware_layers/neuron.cpp @@ -264,7 +264,7 @@ void searchForIO() // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { searchForIO(); } diff --git a/webserver/core/hardware_layers/pixtend.cpp b/webserver/core/hardware_layers/pixtend.cpp index 8f5b80e..c2097ff 100755 --- a/webserver/core/hardware_layers/pixtend.cpp +++ b/webserver/core/hardware_layers/pixtend.cpp @@ -813,7 +813,7 @@ void *updateLocalBuffers(void *args) // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { Spi_Setup(0); Spi_Setup(1); diff --git a/webserver/core/hardware_layers/pixtend2l.cpp b/webserver/core/hardware_layers/pixtend2l.cpp index 2f89b6d..90e5687 100644 --- a/webserver/core/hardware_layers/pixtend2l.cpp +++ b/webserver/core/hardware_layers/pixtend2l.cpp @@ -596,7 +596,7 @@ void *updateLocalBuffers(void *args) // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { Spi_SetupV2(0); Spi_SetupV2(1); diff --git a/webserver/core/hardware_layers/pixtend2s.cpp b/webserver/core/hardware_layers/pixtend2s.cpp index 647f25f..3afe013 100755 --- a/webserver/core/hardware_layers/pixtend2s.cpp +++ b/webserver/core/hardware_layers/pixtend2s.cpp @@ -533,7 +533,7 @@ void *updateLocalBuffers(void *args) // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { Spi_SetupV2(0); Spi_SetupV2(1); diff --git a/webserver/core/hardware_layers/psm.cpp b/webserver/core/hardware_layers/psm.cpp index 85385a9..e3e03fe 100644 --- a/webserver/core/hardware_layers/psm.cpp +++ b/webserver/core/hardware_layers/psm.cpp @@ -414,7 +414,7 @@ void kill_psm() // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { //Verify if there is any old PSM running on the background and kill it if ((psm = connect_to_psm(0)) >= 0) diff --git a/webserver/core/hardware_layers/raspberrypi.cpp b/webserver/core/hardware_layers/raspberrypi.cpp index e813951..e8f30bc 100755 --- a/webserver/core/hardware_layers/raspberrypi.cpp +++ b/webserver/core/hardware_layers/raspberrypi.cpp @@ -65,7 +65,7 @@ int analogOutBufferPinMask[MAX_ANALOG_OUT] = { 18 }; // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { gpioInitialise(); //piHiPri(99); diff --git a/webserver/core/hardware_layers/raspberrypi_old.cpp b/webserver/core/hardware_layers/raspberrypi_old.cpp index c949a9d..2560ae5 100755 --- a/webserver/core/hardware_layers/raspberrypi_old.cpp +++ b/webserver/core/hardware_layers/raspberrypi_old.cpp @@ -66,7 +66,7 @@ int analogOutBufferPinMask[MAX_ANALOG_OUT] = { 1 }; // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { wiringPiSetup(); //piHiPri(99); diff --git a/webserver/core/hardware_layers/sequent.cpp b/webserver/core/hardware_layers/sequent.cpp index 725e2f7..7a72ea7 100644 --- a/webserver/core/hardware_layers/sequent.cpp +++ b/webserver/core/hardware_layers/sequent.cpp @@ -1665,7 +1665,7 @@ int mosfets8Set(uint8_t stack, uint8_t val) // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { } diff --git a/webserver/core/hardware_layers/simulink.cpp b/webserver/core/hardware_layers/simulink.cpp index d30be0a..727356b 100755 --- a/webserver/core/hardware_layers/simulink.cpp +++ b/webserver/core/hardware_layers/simulink.cpp @@ -162,7 +162,7 @@ void *exchangeData(void *arg) // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { pthread_t thread; pthread_create(&thread, NULL, exchangeData, NULL); diff --git a/webserver/core/hardware_layers/sl_rp4.cpp b/webserver/core/hardware_layers/sl_rp4.cpp index c520b26..ebd9d66 100644 --- a/webserver/core/hardware_layers/sl_rp4.cpp +++ b/webserver/core/hardware_layers/sl_rp4.cpp @@ -125,7 +125,7 @@ int16_t getSwitchId() // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { } diff --git a/webserver/core/hardware_layers/unipi.cpp b/webserver/core/hardware_layers/unipi.cpp index 76f4e0b..558324b 100755 --- a/webserver/core/hardware_layers/unipi.cpp +++ b/webserver/core/hardware_layers/unipi.cpp @@ -160,7 +160,7 @@ int mcp_adcRead(int chan) // This function is called by the main OpenPLC routine when it is initializing. // Hardware initialization procedures should be here. //----------------------------------------------------------------------------- -void initializeHardware(custom_layer_options& customLayerOptions) +void initializeHardware() { wiringPiSetup(); mcp_adcSetup(0x68); //ADC I2C address configuration diff --git a/webserver/core/ladder.h b/webserver/core/ladder.h index 07d5dcd..e49e87d 100644 --- a/webserver/core/ladder.h +++ b/webserver/core/ladder.h @@ -104,7 +104,7 @@ void glueVars(); void updateTime(); //hardware_layer.cpp -void initializeHardware(custom_layer_options& customLayerOptions); +void initializeHardware(); void finalizeHardware(); void updateBuffersIn(); void updateBuffersOut(); @@ -155,7 +155,7 @@ int processEnipMessage(unsigned char *buffer, int buffer_size); uint16_t processPCCCMessage(unsigned char *buffer, int buffer_size); //modbus_master.cpp -void initializeMB(custom_layer_options& customLayerOptions); +void initializeMB(); void *querySlaveDevices(void *arg); void updateBuffersIn_MB(); void updateBuffersOut_MB(); diff --git a/webserver/core/main.cpp b/webserver/core/main.cpp index 7960cd2..17cbeaa 100644 --- a/webserver/core/main.cpp +++ b/webserver/core/main.cpp @@ -32,7 +32,6 @@ #include "iec_types.h" #include "ladder.h" -#include "custom_layer_options.h" #ifdef _ethercat_src #include "ethercat_src.h" #endif @@ -265,11 +264,8 @@ int main(int argc,char **argv) type_logger_callback logger = logger_callback; ethercat_configure("../utils/ethercat_src/build/ethercat.cfg", logger); #endif - // Create layer options struct to pass settings between hardware layers and other init methods - custom_layer_options customLayerOptions; - - initializeHardware(customLayerOptions); - initializeMB(customLayerOptions); + initializeHardware(); + initializeMB(); initCustomLayer(); updateBuffersIn(); updateCustomIn(); diff --git a/webserver/core/modbus_master.cpp b/webserver/core/modbus_master.cpp index 82a4936..69fb4d9 100755 --- a/webserver/core/modbus_master.cpp +++ b/webserver/core/modbus_master.cpp @@ -610,7 +610,7 @@ void *querySlaveDevices(void *arg) // This function is called by the main OpenPLC routine when it is initializing. // Modbus master initialization procedures are here. //----------------------------------------------------------------------------- -void initializeMB(custom_layer_options& customLayerOptions) +void initializeMB() { parseConfig();