From 6a39116056427fb17427c6b26adbae91d2c6a992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Raimbault?= Date: Mon, 21 Oct 2024 18:25:08 +0200 Subject: [PATCH] Use port 502 instead of 1502 in documentation (closes #771) The default port number of Modbus is 502 but it requires privileges on Linux. --- docs/modbus_new_tcp.md | 2 +- docs/modbus_new_tcp_pi.md | 2 +- docs/modbus_read_registers.md | 2 +- docs/modbus_send_raw_request.md | 2 +- docs/modbus_send_raw_request_tid.md | 2 +- docs/modbus_set_socket.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/modbus_new_tcp.md b/docs/modbus_new_tcp.md index 1bb2ae944..3843db760 100644 --- a/docs/modbus_new_tcp.md +++ b/docs/modbus_new_tcp.md @@ -41,7 +41,7 @@ defined below. ```c modbus_t *ctx; -ctx = modbus_new_tcp("127.0.0.1", 1502); +ctx = modbus_new_tcp("127.0.0.1", 502); if (ctx == NULL) { fprintf(stderr, "Unable to allocate libmodbus context\n"); return -1; diff --git a/docs/modbus_new_tcp_pi.md b/docs/modbus_new_tcp_pi.md index fa0b5c0ca..d57e81aa9 100644 --- a/docs/modbus_new_tcp_pi.md +++ b/docs/modbus_new_tcp_pi.md @@ -42,7 +42,7 @@ defined below. ```c modbus_t *ctx; -ctx = modbus_new_tcp_pi("::1", "1502"); +ctx = modbus_new_tcp_pi("::1", "502"); if (ctx == NULL) { fprintf(stderr, "Unable to allocate libmodbus context\n"); return -1; diff --git a/docs/modbus_read_registers.md b/docs/modbus_read_registers.md index 8f853cc7c..265540025 100644 --- a/docs/modbus_read_registers.md +++ b/docs/modbus_read_registers.md @@ -38,7 +38,7 @@ uint16_t tab_reg[64]; int rc; int i; -ctx = modbus_new_tcp("127.0.0.1", 1502); +ctx = modbus_new_tcp("127.0.0.1", 502); if (modbus_connect(ctx) == -1) { fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno)); modbus_free(ctx); diff --git a/docs/modbus_send_raw_request.md b/docs/modbus_send_raw_request.md index 66ceceaa2..f71e1463a 100644 --- a/docs/modbus_send_raw_request.md +++ b/docs/modbus_send_raw_request.md @@ -38,7 +38,7 @@ uint8_t raw_req[] = { 0xFF, MODBUS_FC_READ_HOLDING_REGISTERS, 0x00, 0x01, 0x0, 0 int req_length; uint8_t rsp[MODBUS_TCP_MAX_ADU_LENGTH]; -ctx = modbus_new_tcp("127.0.0.1", 1502); +ctx = modbus_new_tcp("127.0.0.1", 502); if (modbus_connect(ctx) == -1) { fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno)); modbus_free(ctx); diff --git a/docs/modbus_send_raw_request_tid.md b/docs/modbus_send_raw_request_tid.md index 69dc4e13c..6d4470fb0 100644 --- a/docs/modbus_send_raw_request_tid.md +++ b/docs/modbus_send_raw_request_tid.md @@ -40,7 +40,7 @@ uint8_t raw_req[] = { 0xFF, MODBUS_FC_READ_HOLDING_REGISTERS, 0x00, 0x01, 0x0, 0 int req_length; uint8_t rsp[MODBUS_TCP_MAX_ADU_LENGTH]; -ctx = modbus_new_tcp("127.0.0.1", 1502); +ctx = modbus_new_tcp("127.0.0.1", 502); if (modbus_connect(ctx) == -1) { fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno)); modbus_free(ctx); diff --git a/docs/modbus_set_socket.md b/docs/modbus_set_socket.md index cdf811b5b..5fb91a07b 100644 --- a/docs/modbus_set_socket.md +++ b/docs/modbus_set_socket.md @@ -23,7 +23,7 @@ The function shall return 0 if successful. Otherwise it shall return -1 and set ## Example ```c -ctx = modbus_new_tcp("127.0.0.1", 1502); +ctx = modbus_new_tcp("127.0.0.1", 502); server_socket = modbus_tcp_listen(ctx, NB_CONNECTION); FD_ZERO(&rdset);