• Recent
    • Tags
    • Popular
    • Register
    • Login
    1. Home
    2. gbccccc

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website
    G
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    gbccccc

    @gbccccc

    0
    Reputation
    1
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    gbccccc Unfollow Follow

    Latest posts made by gbccccc

    • Feature Request: run the main loop of start() method of TcpSlave/UdpSlave in another thread

      Thanks for you guys' easy-of-use Modbus implementation at the beginning!

      Recently I have been developing a web system used to test Modbus (TCP) devices. What I want to implement now is to offer system users an API to create some Modbus slaves running on the server.
      However, when I want to return whether the new slave is started successfully (IMO, main loop start can means success) to the frontend, it turns out that tcpSlave.start() won't end until an exception happened. If I run this method in a new thread, still I cannot detect whether the slave is started successfully or the port has been occupied. Ways like setting a timeout are not elegant IMO. I think if the main loop of this method is run in a new thread instead of the main thread calling the method, it will be much more convenient for me to use this method.

      Regarding code:

          /** {@inheritDoc} */
          @Override
          public void start() throws ModbusInitException {
              try {
                  serverSocket = new ServerSocket(port);
      
                  Socket socket;
                  while (true) {
                      socket = serverSocket.accept();
                      TcpConnectionHandler handler = new TcpConnectionHandler(socket);
                      executorService.execute(handler);
                      synchronized (listConnections) {
                          listConnections.add(handler);
                      }
                  }
              }
              catch (IOException e) {
                  throw new ModbusInitException(e);
              }
          }
      
      posted in Wishlist
      G
      gbccccc