mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-13 11:19:52 +03:00
update to eModbus 1.7.4
This commit is contained in:
@@ -50,6 +50,11 @@ public:
|
||||
// Remove all pending request from queue
|
||||
void clearQueue();
|
||||
|
||||
// Set number of timeouts to tolerate before a connection is forcibly closed.
|
||||
// 0: never, 1..255: desired number
|
||||
// Returns previous value.
|
||||
uint8_t closeConnectionOnTimeouts(uint8_t n=3);
|
||||
|
||||
protected:
|
||||
// class describing a target server
|
||||
struct TargetHost {
|
||||
@@ -58,7 +63,7 @@ protected:
|
||||
uint32_t timeout; // Time in ms waiting for a response
|
||||
uint32_t interval; // Time in ms to wait between requests
|
||||
|
||||
inline TargetHost& operator=(TargetHost& t) {
|
||||
inline TargetHost& operator=(const TargetHost& t) {
|
||||
host = t.host;
|
||||
port = t.port;
|
||||
timeout = t.timeout;
|
||||
@@ -66,7 +71,7 @@ protected:
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline TargetHost(TargetHost& t) :
|
||||
inline TargetHost(const TargetHost& t) :
|
||||
host(t.host),
|
||||
port(t.port),
|
||||
timeout(t.timeout),
|
||||
@@ -86,13 +91,13 @@ protected:
|
||||
interval(interval)
|
||||
{ }
|
||||
|
||||
inline bool operator==(TargetHost& t) {
|
||||
inline bool operator==(const TargetHost& t) {
|
||||
if (host != t.host) return false;
|
||||
if (port != t.port) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool operator!=(TargetHost& t) {
|
||||
inline bool operator!=(const TargetHost& t) {
|
||||
if (host != t.host) return true;
|
||||
if (port != t.port) return true;
|
||||
return false;
|
||||
@@ -135,7 +140,7 @@ protected:
|
||||
}
|
||||
|
||||
protected:
|
||||
uint8_t headRoom[6]; // Buffer to hold MSB-first TCP header
|
||||
uint8_t headRoom[6] = {0,0,0,0,0,0}; // Buffer to hold MSB-first TCP header
|
||||
};
|
||||
|
||||
struct RequestEntry {
|
||||
@@ -144,7 +149,7 @@ protected:
|
||||
TargetHost target;
|
||||
ModbusTCPhead head;
|
||||
bool isSyncRequest;
|
||||
RequestEntry(uint32_t t, ModbusMessage m, TargetHost tg, bool syncReq = false) :
|
||||
RequestEntry(uint32_t t, const ModbusMessage& m, TargetHost tg, bool syncReq = false) :
|
||||
token(t),
|
||||
msg(m),
|
||||
target(tg),
|
||||
@@ -153,8 +158,8 @@ protected:
|
||||
};
|
||||
|
||||
// Base addRequest and syncRequest must be present
|
||||
Error addRequestM(ModbusMessage msg, uint32_t token);
|
||||
ModbusMessage syncRequestM(ModbusMessage msg, uint32_t token);
|
||||
Error addRequestM(ModbusMessage msg, uint32_t token) override;
|
||||
ModbusMessage syncRequestM(ModbusMessage msg, uint32_t token) override;
|
||||
// TCP-specific addition "...MT()" including adhoc target - used by bridge
|
||||
Error addRequestMT(ModbusMessage msg, uint32_t token, IPAddress targetHost, uint16_t targetPort);
|
||||
ModbusMessage syncRequestMT(ModbusMessage msg, uint32_t token, IPAddress targetHost, uint16_t targetPort);
|
||||
@@ -174,7 +179,6 @@ protected:
|
||||
// receive: get response via Client connection
|
||||
ModbusMessage receive(RequestEntry *request);
|
||||
|
||||
void isInstance() { return; } // make class instantiable
|
||||
queue<RequestEntry *> requests; // Queue to hold requests to be processed
|
||||
#if USE_MUTEX
|
||||
mutex qLock; // Mutex to protect queue
|
||||
@@ -185,6 +189,8 @@ protected:
|
||||
uint32_t MT_defaultTimeout; // Standard timeout value taken if no dedicated was set
|
||||
uint32_t MT_defaultInterval; // Standard interval value taken if no dedicated was set
|
||||
uint16_t MT_qLimit; // Maximum number of requests to accept in queue
|
||||
uint8_t MT_timeoutsToClose; // 0: disregard, 1-255: number of timeouts to tolerate before
|
||||
// forcibly closing a connection.
|
||||
|
||||
// Let any ModbusBridge class use protected members
|
||||
template<typename SERVERCLASS> friend class ModbusBridge;
|
||||
|
||||
Reference in New Issue
Block a user