Comments (6)
Look at (private) method _disconnect:
esp32ModbusTCP/src/esp32ModbusTCP.cpp
Line 107 in 8621d98
from esp32modbustcp.
Hi bertmelis
Thank you very much for the rapid response. My knowledge is a very thin veneer and I have extremely limited knowledge of libraries.
I had a look at
void esp32ModbusTCP::_disconnect(bool now) {
log_v("disconnecting");
_state = DISCONNECTING;
_client.close(now);
}
in the esp32ModbusTCP.cpp.
Based on the the other functions within the library I would have expected
sunnyisland.disconnect(true);
to be the appropriate function call to disconnect and close the sunnyisland client.
I’m working in VSCode and intellisens is indicating that
class “esp32ModbusTCP” has no member “disconnect”
Clearly I’m missing something and I’m hoping you could again please point me in the right direction.
I fiddled and I mean I’m fiddling in the dark, I tried
sunnyisland.~esp32ModbusTCP.disconnect(true);
and intellisens seems to like it :)
Edit...but it didn’t compile with a does not have class type error.
Hopefully you can give me a bit more guidance please.
Many thanks
Carl
from esp32modbustcp.
You need to do a few steps:
make the function public. It's private now. So move the function in the .h file from the private section the the public section.
Maybe rename the function: remove the underscore. But you'll also have to change the name in all places that call the function (in the cpp file).
Does this make sense to you?
from esp32modbustcp.
Hi bertmelis
Thanks for the even more rapid response.
I’ll give it a bash and see if I get it right.
In reading the original library more closely I notice that writing to registers is not implemented. I’ll try my luck with this too.
Or would you recommend I rather move to v1 and adjust my sketch accordingly? I would still need to change the header to make the .disconnect() public, but it appears that the register write has been implemented.
Many thanks
Carl
from esp32modbustcp.
Hi bertmelis
I followed your guidance above, thank you.
“You need to do a few steps: make the function public. It's private now. So move the function in the .h file from the private section the the public section.”
Done. I commented it out in the private section and pasted it into public after readInputRegisters line.
I removed the underscore as suggested.
LBut you'll also have to change the name in all places that call the function (in the cpp file).”
There were only two instances where _disconnect is called in the .cpp file and I deleted the underscore to match the .h.
The intellisens was seeing the public function .connect and the sketch compiles.
However no matter what I use it does not seem to disconnect the link, as I continue to get read errors. I tried
sunnyisland.disconnect();
sunnyisland.disconnect(true);
sunnyisland.disconnect(now);
sunnyisland.disconnect(false);
I then resorted to commenting out the sunnyisland.disconnect() and just did not read the holdingregister for 180s. This did not reset the link either, even though #define MB_IDLE_DISCONNECT_TIME is set to 10000ms. I then powered the ESP32 off for 180s and then powered it up. Now the link is up and the holdingregister is being successfully read. This physical power cycle with the 3 minute delay (2 minutes is too short) does it every time so far.
Any guidance would be appreciated.
Many thanks
Carl
from esp32modbustcp.
Hi bertmelis
I have installed v1 library, adjusted for the load prohibited error by commenting out the two lines in esp32ModbusTCP.cpp, adjusted code to examples, compiled and uploaded fine.
However the esp32 is now rebooting after the first SI holdingregister read per below.
SI reading error
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d1ee1 PS : 0x00060430 A0 : 0x800e41d4 A1 : 0x3ffde7a0
A2 : 0x3ffde7ec A3 : 0x3ffde7e4 A4 : 0x3ffde7e2 A5 : 0x3ffde7e3
A6 : 0x3ffde7e8 A7 : 0x3ffde7e6 A8 : 0x3ffdecf1 A9 : 0x00000000
A10 : 0x00000008 A11 : 0x00000001 A12 : 0x00000005 A13 : 0x00000020
A14 : 0x00000020 A15 : 0x3ffbc830 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000008 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0xffffffff
Backtrace: 0x400d1ee1:0x3ffde7a0 0x400e41d1:0x3ffde7c0 0x400e45d5:0x3ffde810 0x4016507d:0x3ffde840 0x400e4e29:0x3ffde860 0x400e4e6d:0x3ffde8a0 0x400e52d6:0x3ffde8c0 0x40089805:0x3ffde8f0
Rebooting...
Hopefully this helps you to identify the problem.
Cheers
Carl
from esp32modbustcp.
Related Issues (17)
- SMA.ino with a SMA inverter - getting error e4 for each register read HOT 10
- Writing data in to a holding register. HOT 10
- modbus sunny boy + LCD I2C 20x4 HOT 1
- Bad message response HOT 16
- requirements for this library to work? HOT 1
- Problems with connection and comunication! HOT 23
- Load prohibited on tcp timeout HOT 2
- Is it possible to use this along with the encj28j60 Ethernet module for the esp32? HOT 1
- Sample run error
- SLAVE implemention ? HOT 1
- onData/onError callbacks are not called in the example code. HOT 2
- ERROR HOT 1
- expected declaration before '}' token HOT 5
- Debug problem HOT 3
- Suggestion on how to read from two Slaves at the same time HOT 5
- Is it running on ESP8266 ? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp32modbustcp.