I wanted to ask how to query every second Modbus, using the JAMOD library. Decided to make a preliminary connection to Modbus and then, within a loop while(true) query the Modbus. After interrogating the device, use a Thread.sleep (1000); is the right way? Thank you.
Asked
Active
Viewed 297 times
2 Answers
1
You should create a Thread
(something that implements Runnable
).
See this answer : https://stackoverflow.com/a/426795/362332
0
//I usually use asynchronous threads to process
//example
@Async
public Future<Integer> loop() {
while (true) {
int value = modbusServer.read(1001);
if (value == 1) {
//Business processing ...
break;
}
thread.sleep(50);
}
return new AsyncResult(1);
}