ESP32 MODBUS descriptor CID field issue

ESP_alisitsyn
Posts: 203
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: ESP32 MODBUS descriptor CID field issue

Postby ESP_alisitsyn » Mon Mar 14, 2022 9:19 am

Hi @Ashvajit.P,

Sorry for the late response, please try to use the last patch from the topic below and increase the CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND, and disable the CONFIG_FMB_TIMER_PORT_ENABLED value in Modbus configuration.

https://github.com/espressif/esp-idf/issues/6134

Unfortunately, I can not provide you with the exact solution for this issue because I need more information about your projects and versions of IDF.

Ashvajit.P
Posts: 34
Joined: Fri Feb 26, 2021 9:03 am

Re: ESP32 MODBUS descriptor CID field issue

Postby Ashvajit.P » Mon Mar 28, 2022 9:25 am

The following are my project and IDF details for the same project.

ESP_IDF checkout : v4.3.1
Toolchain : GCC 8.4.0, GDB : 8.1.0, ESP-IDF 4.2, Revision 6

Let me know if I am missing anything.

Also I observed that after restarting ESP after programming the first time. Resource release failure is occurring rarely.
I also wanted to know that are there any available APIs for multiple write and read MODBUS registers
instead of using single read/write commands ?

ESP_alisitsyn
Posts: 203
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: ESP32 MODBUS descriptor CID field issue

Postby ESP_alisitsyn » Wed Mar 30, 2022 8:27 am

Hi,

Thank you for information.
Currently for reading and writing the holding registers stack uses the MB_FUNC_READ_HOLDING_REGISTER:MB_FUNC_WRITE_MULTIPLE_REGISTERS accordingly. It is a pretty typical approach for Modbus master. If absolutely required you can use the API https://github.com/espressif/esp-idf/bl ... ter.c#L166 that can be made public for your project through CMakeLists.txt file.

The resource release failure can be related to the slave response after timeout.
Please try to apply the v4.3 patch from this post to solve the issue:
https://github.com/espressif/esp-idf/issues/6134
Please then increase the CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND time in kconfig and disable the CONFIG_FMB_TIMER_PORT_ENABLED.
Let me know If you have any issues applying the patch. There is a delay with the final solution but it will be available soon.

Ashvajit.P
Posts: 34
Joined: Fri Feb 26, 2021 9:03 am

Re: ESP32 MODBUS descriptor CID field issue

Postby Ashvajit.P » Wed Mar 30, 2022 10:12 am

Thanks for the response ,

I'll try to apply the pacth for the resource failure issue.
If absolutely required you can use the API https://github.com/espressif/esp-idf/bl ... ter.c#L166 that can be made public for your project through CMakeLists.txt file.
Do you have any reference/ example to implement multiple read/ write registers using above mentioned function. I did found that static API (esp_err_t mbc_serial_master_send_request(mb_param_request_t* request, void* data_ptr)) while searching through the library but not sure how to implement it.

ESP_alisitsyn
Posts: 203
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: ESP32 MODBUS descriptor CID field issue

Postby ESP_alisitsyn » Wed Mar 30, 2022 11:59 am

@Ashvajit.P

The `mbc_serial_master_send_request(mb_param_request_t* request, void* data_ptr));` can be accessed through the function `mbc_master_send_request()`
https://github.com/espressif/esp-idf/bl ... ster.c#L83 which will translate the call to `mbc_serial_master_send_request()`.
An example of using of the function for standard commands:
https://github.com/alisitsyn/modbus_sup ... r.cpp#L173

The `mbc_serial_master_send_request` can be made public by removing the `static` attribute and exposing the func prototype through the your project CMakeLists.txt. The dependency injection technique can allow calling this static func from your code as well.
However, it is a hard tricks and I do not recommend this because of the public available API.

Ashvajit.P
Posts: 34
Joined: Fri Feb 26, 2021 9:03 am

Re: ESP32 MODBUS descriptor CID field issue

Postby Ashvajit.P » Tue Apr 05, 2022 4:56 am

I implemented MODBUS read/write using the API you suggested and it is working now.
Thanks for your support !! :D :D

ESP_alisitsyn
Posts: 203
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: ESP32 MODBUS descriptor CID field issue

Postby ESP_alisitsyn » Tue Apr 05, 2022 6:46 am

@Ashvajit.P ,

You are welcome! Good luck with your project!

Who is online

Users browsing this forum: jm2935 and 98 guests