-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modbus - assert occurs when mbc_master_destroy is called while a transaction is still ongoing (IDFGH-3283) #5275
Comments
… ongoing Jira: espressif#5275 - patched unexpected event as timeouts rather than causing reset. Signed-off-by: Simon THIEBAUT <simon.thiebaut@zodiac.com>
… ongoing bugfix: Modbus causes assert when destroying stack while requests are ongoing Jira: espressif#5275 - patched unexpected event as timeouts rather than causing reset. Signed-off-by: Simon THIEBAUT <simon.thiebaut@zodiac.com>
Thanks for reporting, we will look into. |
Thank you for this issue and good description of it. I was able to reproduce the issue. Are you able to initialize and restart modbus communication after destroy? |
Thank you all for the feedback. So actually in our current use case:
So for now unfortunately I cannot answer your question @alisitsyn ... |
@simon-thiebaut, |
@simon-thiebaut, |
@alisitsyn many thanks for the fix 👍 ! |
… ongoing bugfix: Modbus causes assert when destroying stack while requests are ongoing Jira: espressif#5275 - patched unexpected event as timeouts rather than causing reset. Signed-off-by: Simon THIEBAUT <simon.thiebaut@zodiac.com>
… ongoing bugfix: Modbus causes assert when destroying stack while requests are ongoing Jira: espressif#5275 - patched unexpected event as timeouts rather than causing reset. Signed-off-by: Simon THIEBAUT <simon.thiebaut@zodiac.com>
… ongoing bugfix: Modbus causes assert when destroying stack while requests are ongoing Jira: espressif#5275 - patched unexpected event as timeouts rather than causing reset. Signed-off-by: Simon THIEBAUT <simon.thiebaut@zodiac.com>
Closes espressif/esp-idf#5275 * Original commit: espressif/esp-idf@3bbdfb7
Environment
git describe --tags
to find it): v4.0-dev-2599-gcb9398aee (actually we've forked the repo to do modifications, but I have checked, the code chunk causing issue is up to date with the master repo)xtensa-esp32-elf-gcc --version
to find it): not relevantProblem Description
Our application needs to destroy the Modbus stack on the fly, while requests can still be pending.
What happens is that when it occurs, instruction "assert(0);" gets called in function eMBMasterWaitRequestFinish.
After investigations, here is what occurs:
The reason why event EV_MASTER_NO_EVENT gets called is that mbc_master_destroy calls vMBMasterPortEventClose which calls vEventGroupDelete(xEventGroupMasterHdl).
And the fact is that this FreeRTOS call will unblock any task waiting on the event group to be deleted by sending 0 before deleting the event group (see comment event_groups.c => /* Unblock the task, returning 0 as the event list is being deleted and cannot therefore have any bits set. */
For now, I have patched by replacing in eMBMasterWaitRequestFinish "assert(0);" by "eErrStatus = MB_MRE_TIMEDOUT;", so that current transaction finishes properly and sees unanswered frame as a timeout.
Expected Behavior
I was expecting to be able to destroy the Modbus stack safely whatever its state is.
Actual Behavior
Assert occurs when destroying the Modbus stack.
Steps to reproduce
Debug Logs
...
[0;31mE (7780) MB_PORT_COMMON: eMBMasterWaitRequestFinish: Incorrect event or timeout xRecvedEvent = 0x0�[0m
assertion "0" failed: file "../esp-idf/components/freemodbus/port/portevent_m.c", line 284, function: eMBMasterWaitRequestFinish
abort() was calle�[0;31mE (d at PC 0x401ae2a7 on core 0
ELF file SHA256: 18944071bb28af0b60745f472cd4821d3f49699ada946576a7c2e1a9bfeb6bbf
Backtrace: 0x40091207:0x3ffdc9f0 0x40091660:0x3ffdca20 0x401ae2a7:0x3ffdca50 0x400e9b1a:0x3ffdca80 0x400eb82c:0x3ffdcac0 0x400e7c79:0x3ffdcaf0 0x400e7e9e:0x3ffdcb30 0x400e5c63:0x3ffdcba0 0x400d7f44:0x3ffdcbe0 0x400d76ec:0x3ffdcc30
Rebooting...
ets Jun 8 2016 00:22:57
...
Thank you for the feedback. Please let me know if you need further info or if stack is not expected to be used that why.
The text was updated successfully, but these errors were encountered: