I am working on modbus device which is connected with system through serial port. I can read/write data on device's register. I am using java for data read/write.
The device automatically turns off on every 10 seconds, to keep it activated I need to establish the connection on every 10 seconds. How can I achieve this requirement?
You can use timer class to establish connection every 10 seconds as such:
class EstablishConnection extends TimerTask {
public void run() {
// Code to establish connection
}
}
Timer timer = new Timer();
timer.schedule(new EstablishConnection(), 0, 10000);