Skip to content

Commit

Permalink
Use port 502 instead of 1502 in documentation (closes #771)
Browse files Browse the repository at this point in the history
The default port number of Modbus is 502 but it requires privileges on
Linux.
  • Loading branch information
stephane committed Oct 21, 2024
1 parent 7de0bcb commit 6a39116
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/modbus_new_tcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion docs/modbus_new_tcp_pi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion docs/modbus_read_registers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion docs/modbus_send_raw_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion docs/modbus_send_raw_request_tid.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion docs/modbus_set_socket.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6a39116

Please sign in to comment.