GithubHelp home page GithubHelp logo

Comments (6)

bertmelis avatar bertmelis commented on May 29, 2024

Look at (private) method _disconnect:

void esp32ModbusTCP::_disconnect(bool now) {

from esp32modbustcp.

CarlSchneider avatar CarlSchneider commented on May 29, 2024

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.

bertmelis avatar bertmelis commented on May 29, 2024

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.

CarlSchneider avatar CarlSchneider commented on May 29, 2024

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.

CarlSchneider avatar CarlSchneider commented on May 29, 2024

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.

CarlSchneider avatar CarlSchneider commented on May 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.