eModbus / eModbus

Modbus library for RTU, ASCII and TCP protocols. Primarily developed on and for ESP32 MCUs.

Home Page:https://emodbus.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ModbusClient TCP how to stop a running work task

Miq1 opened this issue · comments

Discussed in #277

Originally posted by dima-sz March 10, 2023
ModbusClient TCP how to stop a running worker task started by calling begin(int coreID)?

I added ModbusClientTCP::end() to the master branch. I would ask you to test it and report your findings here.

Argh. Missed an if (worker) { ... } there. Will fix that asap.

Thank you for testing it!

Thanks again - I fixed it a minute ago in master. Could you give it another try?

Thanks for verifying!

Can we have a full exception dump please?

The error hints f.i. to a use of a single memory area for both clients, where the second tries to access while the first already has freed it. This may happen more often because a connection is tried for 3s before determining it is impossible for offline servers. So the clients will stay in that state without doing anything else.

Do you use the same onData/onError/onResponse handlers for both clients? is there some dynamic data management involved in those functions?

Do you happen to issue the end() while the connection is still hanging for the offline server? There have been reports that killing a TCP client while the polling is still going on results in a dangling pointer in lwIP, hence crashing on the next access to it (see here for an example).

You are using a heck of different TCP services here, both async and synchronous - may be there is a collision sometimes. I have no real idea what could cause the issue...

Any news? Else I would like to close here.

No worries, I will leave it open then. Whenever you find the time I will be eager to learn the outcome.

I am assuming nothing more will be posted here.