From 405b8b71e17facab07dbea0ba23d74a107fe85a6 Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Tue, 14 May 2024 19:00:53 +0200 Subject: [PATCH] Documentation on how to convert string-coded IP adresses. --- include/ecrt.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/ecrt.h b/include/ecrt.h index cc1f1d07..6589554c 100644 --- a/include/ecrt.h +++ b/include/ecrt.h @@ -1880,6 +1880,23 @@ EC_PUBLIC_API int ecrt_slave_config_eoe_mac_address( * This method has to be called in non-realtime context before * ecrt_master_activate(). * + * A string-represented IPv4 address can be converted via ithe POSIX + * function `inet_pton()` (see man 3 inet_pton): + * + * \code{.c} + * #include + * unsigned char buf[sizeof(struct in_addr)]; + * if (inet_pton(AF_INET, "192.168.0.1", buf) <= 0) { + * fprintf(stderr, "Failed to convert IP address.\n"); + * return -1; + * } + * if (ecrt_slave_config_eoe_ip_address(sc, *(uint32_t *) buf)) { + * fprintf(stderr, "Failed to set IP address.\n"); + * return -1; + * } + * \endcode + * + * * \retval 0 Success. * \retval <0 Error code. */