Migration guide for ESP-Modbus

AndreaS73
Posts: 23
Joined: Tue Jan 16, 2024 8:16 am

Migration guide for ESP-Modbus

Postby AndreaS73 » Mon Feb 10, 2025 5:21 am

After upgrading the idf dependencies, the ESP-Modbus component was updated as well (to v2.0.1~1) and now I get dozen of build errors in my code.
Of course that means the functions are changed.

Is there a migration guide that would simplify the adjustment of the code?
If I'm not wrong it seems the examples are still the old version and even the official documentation!
Example, I get this error:
too few arguments to function 'mbc_slave_check_event'
Exploring the source code I find the signature is:

Code: Select all

mb_event_group_t mbc_slave_check_event(void *ctx, mb_event_group_t group)
but the "latest" https://docs.espressif.com/projects/esp ... nt_group_t is not updated yet:

Code: Select all

mb_event_group_t mbc_slave_check_event(mb_event_group_t group)
This is odd. Where is the updated documentation?

ahsrabrifat
Posts: 56
Joined: Sat Jan 18, 2025 2:31 pm

Re: Migration guide for ESP-Modbus

Postby ahsrabrifat » Mon Feb 10, 2025 2:43 pm

Could not find anything except this. :(
https://docs.espressif.com/projects/esp ... rview.html

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

Re: Migration guide for ESP-Modbus

Postby ESP_alisitsyn » Tue Feb 11, 2025 8:58 am

@AndreaS73

Thank you for the comment.
Yes, the new version of esp-modbus v2.0.1 has been released and this has been announced https://github.com/espressif/esp-modbus/discussions/86. Please use the links to the documentation and examples from the discussion link above.
The official examples in esp-idf are still valid and use the esp-idf v1.0.17 (can be compiled correctly without changes) means your legacy project code based on the esp-modbus v1 and https://github.com/espressif/esp-idf/tr ... ols/modbus can still work without changes. These are kept for now in esp-idf during transition period. These examples will be removed from esp-idf on next stable release and the examples from esp-modbus v2 https://github.com/espressif/esp-modbus ... n/examples will become actual. Please take a look to the changes in the examples folder to find the important differences between these versions (the changes are minimal). The API are very similar to esp-modbus v1, but the most important changes are in the signatures of the functions which now include the instance address as a first parameter as described in the documentation https://docs.espressif.com/projects/esp ... us-library.
The version of esp-modbus v2 is the recommended version for future projects and will include the latest updates.

AndreaS73
Posts: 23
Joined: Tue Jan 16, 2024 8:16 am

Re: Migration guide for ESP-Modbus

Postby AndreaS73 » Tue Feb 11, 2025 10:47 am

Thanks for your answer.
I guess the "latest" in the link of the documentation in my first post is misleading since it is not updated (yet?). Your link is correct, but harder to find.
The version of esp-modbus v2 is the recommended version for future projects and will include the latest updates.
We're finalizing a project and we're ready in a couple of months to begin the production.
In my other question (https://esp32.com/viewtopic.php?f=2&t=44321) I described the issues I'm having running the default example of v2: would you recommend to keep v1 for an almost-ready project?

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

Re: Migration guide for ESP-Modbus

Postby ESP_alisitsyn » Tue Feb 11, 2025 11:57 am

I guess the "latest" in the link of the documentation in my first post is misleading since it is not updated (yet?). Your link is correct, but harder to find.
Yes, you are right. This legacy aspect is kind of misleading and will be fixed in coming updates. However, the esp-modbus v2 can work properly for now.
We're finalizing a project and we're ready in a couple of months to begin the production.
In my other question (https://esp32.com/viewtopic.php?f=2&t=44321) I described the issues I'm having running the default example of v2: would you recommend to keep v1 for an almost-ready project?
The transition always take time and it may be safer for you to keep the almost-ready project on v1 for a while and then do this transition to v2, but It is up to you what version to select.

Who is online

Users browsing this forum: No registered users and 95 guests