Menu

Read timed ou

Anonymous
2018-04-06
2018-06-27
  • Anonymous

    Anonymous - 2018-04-06

    I began to study the Modbus protocol. I try to use it for connection, but I get a connection time error. Tell me where I could make a mistake. Thank you.

    ModbusClient modbusClient = new ModbusClient("192.168.127.12", 502);
            try {
                modbusClient.Connect("192.168.127.12", 4001);
                System.out.println("Connected " + modbusClient.isConnected());
                System.out.println("Ip " + modbusClient.getipAddress());
                System.out.println("Port " + modbusClient.getPort());
                System.out.println("UnitIdentifier " + modbusClient.getUnitIdentifier());
                System.out.println("UDPFlag " + modbusClient.getUDPFlag());
                System.out.println("SerialFlag " + modbusClient.getSerialFlag());
                System.out.println("Connect timeout " + modbusClient.getConnectionTimeout());
    
                System.out.println(modbusClient.ReadHoldingRegisters(0x600, 16));
            }
            catch (Exception e) {
                e.printStackTrace();
            }
    

    An error appears when I try to read: java.net.SocketTimeoutException: Read timed out.
    Maybe I'm not correctly addressing the data address on the device. For example, there is: address and HEX 600, data type is WORD array, access to it for reading and size is 16 bytes.
    In the code, I use the function and specify the address and size, after execution, an error occurs: Read timed out. Maybe someone can explain to me where I have a mistake.

    System.out.println(modbusClient.ReadHoldingRegisters(0x600, 16));
    
     
    • Rossmann Engineering

      You are trying to connect to a server listening to Port 4001. As that really intended? Usually a Modbus Server opens port 502.

       
  • Aleksey Malashenkov

     

    Last edit: Aleksey Malashenkov 2018-04-06
  • Anonymous

    Anonymous - 2018-06-01

    Hi, This is Satish, Wanted to check if latest ModbusClient.java file is the one which is using jssc.jar for serial port communication or is it rtrx.jar ?

     
    • Rossmann Engineering

      Hi Satih, it is using RXTX.

       

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.