Small compatibility improvements for esp32 embedded platforms#741
Small compatibility improvements for esp32 embedded platforms#741fedepell wants to merge 2 commits intostephane:masterfrom
Conversation
Some environments, for example lwip, don't have it, so let's make it configurable so we can also build and work on those platforms by simplying using project configuration.
Check via usual autoconf and when not present print just the error code instead of the readable string. Useful for compact embedded stacks where this is not present.
|
We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, please fill https://forms.gle/5635zjphDo5JEJQSA to get added. Your document will be manually checked by the maintainer. Be patient... |
| #endif | ||
|
|
||
| # include <netinet/in.h> | ||
| #ifdef HAVE_NETINET_IP_H |
There was a problem hiding this comment.
ip.h provides IPTOS_LOWDELAYso how this setting is available on ESP32?
There was a problem hiding this comment.
in lwip/sockets.h which comes from netdb.h (above)
|
@fedepell you're right, I don't use Co-authored-by but most of my commits keep the original author (rebase, etc) or I add a ref in commit. It's an oversight I'll add your name to the changelog. |
Thanks and no worries please :) Hope we can (with the appropriate modifications and so on) to put the ESP support in, it works like a charm and is much better than the library provided in the SDK :) |
|
and i also overlooked this. |
| if (rc != 0) { | ||
| if (ctx->debug) { | ||
| #ifdef HAVE_GAI_STRERROR | ||
| fprintf(stderr, "Error returned by getaddrinfo: %s\n", gai_strerror(rc)); |
There was a problem hiding this comment.
why use gai_strerror and not strerror?
There was a problem hiding this comment.
That's a good question ;) But my MR was only to make it conditional (since in ESP-IDF libs there isn't) not to really change the function used. But in case @stephane could consider that! (and then my change would not be needed indeed)
Hi, my sample also runs at serial Port: |
This PR adds a few small compatibility improvements for embedded platforms, specifically for the esp32 family using ESP-IDF, which are based on lwip. With these small modifications and by providing an external
nanosleep(no need to pollute libmodbus as one can provide it externally in the project) then the library can be used in TCP mode in ESP-IDF.The changes are not enough for using it with serial ports, I may send another PR for that (it will be a little more complicated as there we need to change the init part using the UART library for that system).
Would you be interested to have that in case in the codebase? (of course with a separate
#defineto replace themodbus_rtu_connectwhen one chooses that specific platform, a bit like you already have WIN32/Posix differentiation)