I am trying to read the input registers of my PLC through MODBUS TCP using this program But I am getting some Errors.
I am trying to resolve them from so many days but its really impossible for me to do so. Please help me as soon as possible. Below is my program and then errors.
try {
TCPMasterConnection con = null; // the connection
ModbusTCPTransaction trans = null; // the transaction
ReadInputRegistersRequest rreq = null; // the read request
ReadInputRegistersResponse rres = null; // the read response
WriteCoilRequest req = null; // the write request
InetAddress addr = null; // the slave's address
int port = 502; // the default port
int repeat = 3;
run:
--- Message: Line:36 success ---
--- Message: Line:46 success ---
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
Hex Value of register =00 00 00 00 00 00 00 00 00
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:337)
at net.wimpi.modbus.io.ModbusTCPTransport.readResponse(ModbusTCPTransport.java)
at net.wimpi.modbus.io.ModbusTCPTransaction.execute(ModbusTCPTransaction.java)
at javaapplication5.test_modbus.main(test_modbus.java:54)
:::::LINE 54 IS trans.execute();:::::::::::
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am trying to read the input registers of my PLC through MODBUS TCP using this program But I am getting some Errors.
I am trying to resolve them from so many days but its really impossible for me to do so. Please help me as soon as possible. Below is my program and then errors.
PROGRAM;
package javaapplication5;
import net.wimpi.modbus.io.ModbusTCPTransaction;
import net.wimpi.modbus.msg.WriteCoilRequest;
import net.wimpi.modbus.msg.ReadInputRegistersResponse ;
import net.wimpi.modbus.net.TCPMasterConnection;
import java.lang.*;
import java.net.InetAddress;
import net.wimpi.modbus.msg.ReadInputRegistersRequest;
public class test_modbus {
try {
TCPMasterConnection con = null; // the connection
ModbusTCPTransaction trans = null; // the transaction
ReadInputRegistersRequest rreq = null; // the read request
ReadInputRegistersResponse rres = null; // the read response
WriteCoilRequest req = null; // the write request
InetAddress addr = null; // the slave's address
int port = 502; // the default port
int repeat = 3;
}
ERRORS:
run:
--- Message: Line:36 success ---
--- Message: Line:46 success ---
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
Hex Value of register =00 00 00 00 00 00 00 00 00
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:337)
at net.wimpi.modbus.io.ModbusTCPTransport.readResponse(ModbusTCPTransport.java)
at net.wimpi.modbus.io.ModbusTCPTransaction.execute(ModbusTCPTransaction.java)
at javaapplication5.test_modbus.main(test_modbus.java:54)
:::::LINE 54 IS trans.execute();:::::::::::