From 718823f5757a149b8210f25c209fae6be78a26d3 Mon Sep 17 00:00:00 2001 From: M256-Automation <76175329+M256-Automation@users.noreply.github.com> Date: Wed, 14 Dec 2022 15:21:38 +0100 Subject: [PATCH 1/4] Fix error: control reaches end of non-void function --- src/modbusSlave.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modbusSlave.h b/src/modbusSlave.h index 3308b16..f760e1d 100644 --- a/src/modbusSlave.h +++ b/src/modbusSlave.h @@ -46,6 +46,7 @@ class slave { return C.at(_coilAddress); } else { ofLogError("ofxModbusTCP Slave:"+ofToString(idNumber)+" on "+masterIP)<<"Get Slave Coil Exceeds Size"; + return 0; } } int getRegister (int _registerAddress) { @@ -53,6 +54,7 @@ class slave { return R.at(_registerAddress); } else { ofLogError("ofxModbusTCP Slave:"+ofToString(idNumber)+" on "+masterIP)<<"Get Slave Register Exceeds Size"; + return 0; } } From d8b2641c3135d3976c53374c882cabf4762b142b Mon Sep 17 00:00:00 2001 From: M256-Automation <76175329+M256-Automation@users.noreply.github.com> Date: Wed, 14 Dec 2022 15:22:31 +0100 Subject: [PATCH 2/4] Fix error: control reaches end of non-void function --- src/ofxModbusTcpClient.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ofxModbusTcpClient.cpp b/src/ofxModbusTcpClient.cpp index f740839..0df6c37 100644 --- a/src/ofxModbusTcpClient.cpp +++ b/src/ofxModbusTcpClient.cpp @@ -362,6 +362,8 @@ bool ofxModbusTcpClient::getCoil(int _id, int _startAddress) { if (enabled) { if (_id>0 && _id < slaves.size() && _startAddress < numOfCoils) { return slaves.at(_id-1)->getCoil(_startAddress); + } else { + return false; } } else { return false; @@ -371,6 +373,8 @@ int ofxModbusTcpClient::getRegister(int _id, int _startAddress) { if (enabled ) { if (_id>0 && _id < slaves.size() && _startAddress < numOfRegisters) { return slaves.at(_id-1)->getRegister(_startAddress); + } else { + return 0; } } else { return 0; From ff4585de9343ec3d5a848c8d0587ab5fe11950b5 Mon Sep 17 00:00:00 2001 From: M256-Automation <76175329+M256-Automation@users.noreply.github.com> Date: Wed, 14 Dec 2022 15:31:46 +0100 Subject: [PATCH 3/4] new function ofxModbusTcpClient::setup(string _ip, int _numberOfSlaves, int _port) --- src/ofxModbusTcpClient.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ofxModbusTcpClient.cpp b/src/ofxModbusTcpClient.cpp index 0df6c37..f46729c 100644 --- a/src/ofxModbusTcpClient.cpp +++ b/src/ofxModbusTcpClient.cpp @@ -70,12 +70,21 @@ void ofxModbusTcpClient::setup(string _ip, int _numberOfSlaves) { ofLogVerbose("ofxModbusTCP IP:"+ip)<<"Setup with "< 247) { numberOfSlaves = 1; } + ofLogVerbose("ofxModbusTCP IP:"+ip)<<"Setup with "< Date: Wed, 14 Dec 2022 15:32:57 +0100 Subject: [PATCH 4/4] new function ofxModbusTcpClient::setup(string _ip, int _numberOfSlaves, int _port) --- src/ofxModbusTcpClient.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ofxModbusTcpClient.h b/src/ofxModbusTcpClient.h index 25b67c6..dbf046b 100644 --- a/src/ofxModbusTcpClient.h +++ b/src/ofxModbusTcpClient.h @@ -49,6 +49,7 @@ class ofxModbusTcpClient : public ofThread { void setup(string _ip, int _numberOfSlaves); void setup(string _ip); + void setup(string _ip, int _numberOfSlaves, int _port); void connect(); void disconnect();