Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 336d56c

Browse filesBrowse files
committed
ModbusEthernet: Portenta and ESP32 boards build fix
1 parent 6d98023 commit 336d56c
Copy full SHA for 336d56c

File tree

Expand file treeCollapse file tree

3 files changed

+20
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+20
-3
lines changed

‎src/ModbusAPI.h

Copy file name to clipboardExpand all lines: src/ModbusAPI.h
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ uint16_t ModbusAPI<T>::write(TYPEID id, TAddress reg, bool value, cbTransaction
256256
return 0;
257257
}
258258
}
259+
template <class T>
260+
template <typename TYPEID>
259261
uint16_t ModbusAPI<T>::write(TYPEID id, TAddress reg, uint16_t* value, uint16_t numregs, cbTransaction cb, uint8_t unit) {
260262
switch (reg.type) {
261263
case TAddress::COIL:

‎src/ModbusEthernet.h

Copy file name to clipboardExpand all lines: src/ModbusEthernet.h
+18-2Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,32 @@
1010
#endif
1111
#include "ModbusAPI.h"
1212
#include "ModbusTCPTemplate.h"
13-
13+
#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_X8)
14+
#define MODBUS_ETH_WRAP_ACCEPT
15+
#undef MODBUS_ETH_WRAP_BEGIN
16+
#elif defined(ESP32)
17+
#undef MODBUS_ETH_WRAP_ACCEPT
18+
#define MODBUS_ETH_WRAP_BEGIN
19+
#else
20+
#undef MODBUS_ETH_WRAP_ACCEPT
21+
#undef MODBUS_ETH_WRAP_BEGIN
22+
#endif
1423
// Ethernet class wrapper to be able to compile for ESP32
1524
class EthernetServerWrapper : public EthernetServer {
1625
public:
1726
EthernetServerWrapper(uint16_t port) : EthernetServer(port) {
1827

1928
}
29+
#if defined(MODBUS_ETH_WRAP_BEGIN)
2030
void begin(uint16_t port=0) {
21-
31+
EthernetServer::begin();
2232
}
33+
#endif
34+
#if defined(MODBUS_ETH_WRAP_ACCEPT)
35+
inline EthernetClient accept() {
36+
return available();
37+
}
38+
#endif
2339
};
2440

2541
class ModbusEthernet : public ModbusAPI<ModbusTCPTemplate<EthernetServerWrapper, EthernetClient>> {

‎src/ModbusTCPTemplate.h

Copy file name to clipboardExpand all lines: src/ModbusTCPTemplate.h
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ void ModbusTCPTemplate<SERVER, CLIENT>::task() {
259259
Serial.print(n);
260260
Serial.print(": Bytes available ");
261261
Serial.println(tcpclient[n]->available());
262-
#endif
263262
#endif
264263
tcpclient[n]->readBytes(_MBAP.raw, sizeof(_MBAP.raw)); // Get MBAP
265264

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.