Skip to content

Commit 3b1cbe2

Browse files
committed
Switch to leonardo/mega
1 parent a0e2ef8 commit 3b1cbe2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/ModbusIP_ESP8266.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void ModbusIP::task() {
6161
n = getMaster(currentClient->remoteIP());
6262
if (n != -1) {
6363
client[n]->flush();
64-
client[n]->stop();
64+
//client[n]->stop();
6565
delete client[n];
6666
client[n] = nullptr;
6767
}
@@ -74,7 +74,7 @@ void ModbusIP::task() {
7474
}
7575
// Close connection if callback returns false or MODBUSIP_MAX_CLIENTS reached
7676
//currentClient->flush();
77-
currentClient->stop();
77+
//currentClient->stop();
7878
delete currentClient;
7979
}
8080
}
@@ -191,6 +191,7 @@ uint16_t ModbusIP::send(IPAddress ip, TAddress startreg, cbTransaction cb, uint8
191191
tmp.startreg = startreg;
192192
_trans.push_back(tmp);
193193
_frame = nullptr;
194+
_len = 0;
194195
}
195196
return transactionId;
196197
}
@@ -209,6 +210,7 @@ void ModbusIP::cleanup() {
209210
for (uint8_t i = 0; i < MODBUSIP_MAX_CLIENTS; i++) {
210211
if (client[i] && !client[i]->connected()) {
211212
//IPAddress ip = client[i]->remoteIP();
213+
//client[i]->stop();
212214
delete client[i];
213215
client[i] = nullptr;
214216
if (cbDisconnect && cbEnabled)
@@ -406,7 +408,12 @@ void ModbusIP::autoConnect(bool enabled) {
406408

407409
bool ModbusIP::disconnect(IPAddress ip) {
408410
int8_t p = getSlave(ip);
409-
if (p != -1) client[p]->stop();
411+
//if (p != -1) client[p]->stop();
412+
if (p != -1) {
413+
delete client[p];
414+
client[p] = nullptr;
415+
}
416+
return true;
410417
}
411418

412419
void ModbusIP::dropTransactions() {
@@ -418,7 +425,8 @@ ModbusIP::~ModbusIP() {
418425
dropTransactions();
419426
cleanup();
420427
for (uint8_t i = 0; i < MODBUSIP_MAX_CLIENTS; i++) {
421-
client[i]->stop();
428+
//client[i]->stop();
422429
delete client[i];
430+
client[i] = nullptr;
423431
}
424432
}

0 commit comments

Comments
 (0)