Commit 3593d5ad5408fb14607e9ad59f3f6f860c755f37

Authored by Stéphane Raimbault
1 parent 754235c2

Rename slave to server and master to client

.gitignore
@@ -27,11 +27,11 @@ modbus.h @@ -27,11 +27,11 @@ modbus.h
27 *.lo 27 *.lo
28 stamp-h1 28 stamp-h1
29 *.o 29 *.o
30 -tests/bandwidth-master  
31 -tests/bandwidth-slave-many-up  
32 -tests/bandwidth-slave-one  
33 -tests/random-test-master  
34 -tests/random-test-slave  
35 -tests/unit-test-master  
36 -tests/unit-test-slave 30 +tests/bandwidth-client
  31 +tests/bandwidth-server-many-up
  32 +tests/bandwidth-server-one
  33 +tests/random-test-client
  34 +tests/random-test-server
  35 +tests/unit-test-client
  36 +tests/unit-test-server
37 tests/version 37 tests/version
tests/Makefile.am
1 EXTRA_DIST = README 1 EXTRA_DIST = README
2 2
3 noinst_PROGRAMS = \ 3 noinst_PROGRAMS = \
4 - random-test-slave \  
5 - random-test-master \  
6 - unit-test-slave \  
7 - unit-test-master \  
8 - bandwidth-slave-one \  
9 - bandwidth-slave-many-up \  
10 - bandwidth-master \ 4 + random-test-server \
  5 + random-test-client \
  6 + unit-test-server \
  7 + unit-test-client \
  8 + bandwidth-server-one \
  9 + bandwidth-server-many-up \
  10 + bandwidth-client \
11 version 11 version
12 12
13 common_ldflags = \ 13 common_ldflags = \
14 $(top_builddir)/src/libmodbus.la 14 $(top_builddir)/src/libmodbus.la
15 15
16 -random_test_slave_SOURCES = random-test-slave.c  
17 -random_test_slave_LDADD = $(common_ldflags) 16 +random_test_server_SOURCES = random-test-server.c
  17 +random_test_server_LDADD = $(common_ldflags)
18 18
19 -random_test_master_SOURCES = random-test-master.c  
20 -random_test_master_LDADD = $(common_ldflags) 19 +random_test_client_SOURCES = random-test-client.c
  20 +random_test_client_LDADD = $(common_ldflags)
21 21
22 -unit_test_slave_SOURCES = unit-test-slave.c unit-test.h  
23 -unit_test_slave_LDADD = $(common_ldflags) 22 +unit_test_server_SOURCES = unit-test-server.c unit-test.h
  23 +unit_test_server_LDADD = $(common_ldflags)
24 24
25 -unit_test_master_SOURCES = unit-test-master.c unit-test.h  
26 -unit_test_master_LDADD = $(common_ldflags) 25 +unit_test_client_SOURCES = unit-test-client.c unit-test.h
  26 +unit_test_client_LDADD = $(common_ldflags)
27 27
28 -bandwidth_slave_one_SOURCES = bandwidth-slave-one.c  
29 -bandwidth_slave_one_LDADD = $(common_ldflags) 28 +bandwidth_server_one_SOURCES = bandwidth-server-one.c
  29 +bandwidth_server_one_LDADD = $(common_ldflags)
30 30
31 -bandwidth_slave_many_up_SOURCES = bandwidth-slave-many-up.c  
32 -bandwidth_slave_many_up_LDADD = $(common_ldflags) 31 +bandwidth_server_many_up_SOURCES = bandwidth-server-many-up.c
  32 +bandwidth_server_many_up_LDADD = $(common_ldflags)
33 33
34 -bandwidth_master_SOURCES = bandwidth-master.c  
35 -bandwidth_master_LDADD = $(common_ldflags) 34 +bandwidth_client_SOURCES = bandwidth-client.c
  35 +bandwidth_client_LDADD = $(common_ldflags)
36 36
37 version_SOURCES = version.c 37 version_SOURCES = version.c
38 version_LDADD = $(common_ldflags) 38 version_LDADD = $(common_ldflags)
tests/README
@@ -2,37 +2,37 @@ Compilation @@ -2,37 +2,37 @@ Compilation
2 ----------- 2 -----------
3 3
4 After installation, you can use pkg-config to compile these tests. 4 After installation, you can use pkg-config to compile these tests.
5 -For example, to compile random-test-slave run: 5 +For example, to compile random-test-server run:
6 6
7 -gcc random-test-slave.c -o random-test-slave `pkg-config --libs --cflags libmodbus` 7 +gcc random-test-server.c -o random-test-server `pkg-config --libs --cflags libmodbus`
8 8
9 -random-test-slave 9 +random-test-server
10 ----------------- 10 -----------------
11 -It's necessary to launch this server before run random-test-master. By 11 +It's necessary to launch this server before run random-test-client. By
12 default, it receives and responses to Modbus query on the localhost 12 default, it receives and responses to Modbus query on the localhost
13 and port 1502. 13 and port 1502.
14 14
15 -random-test-master 15 +random-test-client
16 ------------------ 16 ------------------
17 This programm sends many different queries to a large range of 17 This programm sends many different queries to a large range of
18 -addresses and values to test the communication between the master and  
19 -the slave. 18 +addresses and values to test the communication between the client and
  19 +the server.
20 20
21 -unit-test-slave  
22 -unit-test-master 21 +unit-test-server
  22 +unit-test-client
23 ---------------- 23 ----------------
24 By default, this program sends some queries with the values defined in 24 By default, this program sends some queries with the values defined in
25 unit-test.h and checks the responses. These programs are useful to 25 unit-test.h and checks the responses. These programs are useful to
26 test the protocol implementation. 26 test the protocol implementation.
27 27
28 -bandwidth-slave-one  
29 -bandwidth-slave-many-up  
30 -bandwidth-master 28 +bandwidth-server-one
  29 +bandwidth-server-many-up
  30 +bandwidth-client
31 ----------------------- 31 -----------------------
32 It returns some very useful informations about the performance of 32 It returns some very useful informations about the performance of
33 -transfert rate between the slave and the master. 33 +transfert rate between the server and the client.
34 34
35 -- bandwidth-slave-one: it can handles only one connection with a master.  
36 -- bandwidth-slave-many-up: it opens a connection each time a new master asks  
37 - for, but the number of connection is limited. The same slave process handles 35 +- bandwidth-server-one: it can handles only one connection with a client.
  36 +- bandwidth-server-many-up: it opens a connection each time a new client asks
  37 + for, but the number of connection is limited. The same server process handles
38 all the connections. 38 all the connections.
tests/bandwidth-master.c renamed to tests/bandwidth-client.c
tests/bandwidth-slave-many-up.c renamed to tests/bandwidth-server-many-up.c
@@ -27,12 +27,12 @@ @@ -27,12 +27,12 @@
27 #define NB_CONNECTION 5 27 #define NB_CONNECTION 5
28 28
29 modbus_t *ctx = NULL; 29 modbus_t *ctx = NULL;
30 -int slave_socket; 30 +int server_socket;
31 modbus_mapping_t *mb_mapping; 31 modbus_mapping_t *mb_mapping;
32 32
33 static void close_sigint(int dummy) 33 static void close_sigint(int dummy)
34 { 34 {
35 - close(slave_socket); 35 + close(server_socket);
36 modbus_free(ctx); 36 modbus_free(ctx);
37 modbus_mapping_free(mb_mapping); 37 modbus_mapping_free(mb_mapping);
38 38
@@ -60,22 +60,22 @@ int main(void) @@ -60,22 +60,22 @@ int main(void)
60 return -1; 60 return -1;
61 } 61 }
62 62
63 - slave_socket = modbus_listen(ctx, NB_CONNECTION); 63 + server_socket = modbus_listen(ctx, NB_CONNECTION);
64 64
65 signal(SIGINT, close_sigint); 65 signal(SIGINT, close_sigint);
66 66
67 /* Clear the reference set of socket */ 67 /* Clear the reference set of socket */
68 FD_ZERO(&refset); 68 FD_ZERO(&refset);
69 - /* Add the slave socket */  
70 - FD_SET(slave_socket, &refset); 69 + /* Add the server socket */
  70 + FD_SET(server_socket, &refset);
71 71
72 /* Keep track of the max file descriptor */ 72 /* Keep track of the max file descriptor */
73 - fdmax = slave_socket; 73 + fdmax = server_socket;
74 74
75 for (;;) { 75 for (;;) {
76 rdset = refset; 76 rdset = refset;
77 if (select(fdmax+1, &rdset, NULL, NULL, NULL) == -1) { 77 if (select(fdmax+1, &rdset, NULL, NULL, NULL) == -1) {
78 - perror("Slave select() failure."); 78 + perror("Server select() failure.");
79 close_sigint(1); 79 close_sigint(1);
80 } 80 }
81 81
@@ -84,7 +84,7 @@ int main(void) @@ -84,7 +84,7 @@ int main(void)
84 for (master_socket = 0; master_socket <= fdmax; master_socket++) { 84 for (master_socket = 0; master_socket <= fdmax; master_socket++) {
85 85
86 if (FD_ISSET(master_socket, &rdset)) { 86 if (FD_ISSET(master_socket, &rdset)) {
87 - if (master_socket == slave_socket) { 87 + if (master_socket == server_socket) {
88 /* A client is asking a new connection */ 88 /* A client is asking a new connection */
89 socklen_t addrlen; 89 socklen_t addrlen;
90 struct sockaddr_in clientaddr; 90 struct sockaddr_in clientaddr;
@@ -93,7 +93,7 @@ int main(void) @@ -93,7 +93,7 @@ int main(void)
93 /* Handle new connections */ 93 /* Handle new connections */
94 addrlen = sizeof(clientaddr); 94 addrlen = sizeof(clientaddr);
95 memset(&clientaddr, 0, sizeof(clientaddr)); 95 memset(&clientaddr, 0, sizeof(clientaddr));
96 - newfd = accept(slave_socket, (struct sockaddr *)&clientaddr, &addrlen); 96 + newfd = accept(server_socket, (struct sockaddr *)&clientaddr, &addrlen);
97 if (newfd == -1) { 97 if (newfd == -1) {
98 perror("Server accept() error"); 98 perror("Server accept() error");
99 } else { 99 } else {
tests/bandwidth-slave-one.c renamed to tests/bandwidth-server-one.c
tests/random-test-master.c renamed to tests/random-test-client.c
tests/random-test-slave.c renamed to tests/random-test-server.c
tests/unit-test-master.c renamed to tests/unit-test-client.c
tests/unit-test-slave.c renamed to tests/unit-test-server.c