Browse Source

Display node and service in PI and port in IPv4 at connection

Stéphane Raimbault 13 years ago
parent
commit
8d8349b860
2 changed files with 6 additions and 2 deletions
  1. 5 1
      src/modbus-tcp.c
  2. 1 1
      tests/unit-test-client.c

+ 5 - 1
src/modbus-tcp.c

@@ -305,7 +305,7 @@ static int _modbus_tcp_connect(modbus_t *ctx)
     }
 
     if (ctx->debug) {
-        printf("Connecting to %s\n", ctx_tcp->ip);
+        printf("Connecting to %s:%d\n", ctx_tcp->ip, ctx_tcp->port);
     }
 
     addr.sin_family = AF_INET;
@@ -368,6 +368,10 @@ static int _modbus_tcp_pi_connect(modbus_t *ctx)
         if (ai_ptr->ai_family == AF_INET)
             _modbus_tcp_set_ipv4_options(s);
 
+        if (ctx->debug) {
+            printf("Connecting to [%s]:%s\n", ctx_tcp_pi->node, ctx_tcp_pi->service);
+        }
+
         rc = _connect(s, ai_ptr->ai_addr, ai_ptr->ai_addrlen, &ctx->response_timeout);
         if (rc == -1) {
             close(s);

+ 1 - 1
tests/unit-test-client.c

@@ -48,7 +48,7 @@ int main(int argc, char *argv[])
     if (argc > 1) {
         if (strcmp(argv[1], "tcp") == 0) {
             use_backend = TCP;
-	} else if (strcmp(argv[1], "tcppi") == 0) {
+    } else if (strcmp(argv[1], "tcppi") == 0) {
             use_backend = TCP_PI;
         } else if (strcmp(argv[1], "rtu") == 0) {
             use_backend = RTU;