Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modbus default port is 502 #771

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 9 additions & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ noinst_PROGRAMS = \
random-test-client \
unit-test-server \
unit-test-client \
version
version \
pv_invertor_simulation \
substation_simulation

common_ldflags = \
$(top_builddir)/src/libmodbus.la
Expand All @@ -34,6 +36,12 @@ unit_test_server_LDADD = $(common_ldflags)
unit_test_client_SOURCES = unit-test-client.c unit-test.h
unit_test_client_LDADD = $(common_ldflags)

pv_invertor_simulation_SOURCES = pv-invertor-simulation.c
pv_invertor_simulation_LDADD = $(common_ldflags)

substation_simulation_SOURCES = substation-simulation.c
substation_simulation_LDADD = $(common_ldflags)

version_SOURCES = version.c
version_LDADD = $(common_ldflags)

Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For example, to compile random-test-server run:

- `random-test-server` is necessary to launch a server before running
random-test-client. By default, it receives and replies to Modbus query on the
localhost and port 1502.
localhost and port 502.

- `random-test-client` sends many different queries to a large range of
addresses and values to test the communication between the client and the
Expand Down
2 changes: 1 addition & 1 deletion tests/bandwidth-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int main(int argc, char *argv[])
}

if (use_backend == TCP) {
ctx = modbus_new_tcp("127.0.0.1", 1502);
ctx = modbus_new_tcp("127.0.0.1", 502);
} else {
ctx = modbus_new_rtu("/dev/ttyUSB1", 115200, 'N', 8, 1);
modbus_set_slave(ctx, 1);
Expand Down
2 changes: 1 addition & 1 deletion tests/bandwidth-server-many-up.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int main(void)
/* Maximum file descriptor number */
int fdmax;

ctx = modbus_new_tcp("127.0.0.1", 1502);
ctx = modbus_new_tcp("127.0.0.1", 502);

mb_mapping =
modbus_mapping_new(MODBUS_MAX_READ_BITS, 0, MODBUS_MAX_READ_REGISTERS, 0);
Expand Down
2 changes: 1 addition & 1 deletion tests/bandwidth-server-one.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main(int argc, char *argv[])
}

if (use_backend == TCP) {
ctx = modbus_new_tcp("127.0.0.1", 1502);
ctx = modbus_new_tcp("127.0.0.1", 502);
s = modbus_tcp_listen(ctx, 1);
modbus_tcp_accept(ctx, &s);

Expand Down
Loading