hi,
I have almost the same problem with the WaitingRoomException.
I set the timeout to different values with the same result, but the message
is received anyways.
output:
request:
00 00 00 00 00 06 03 03 00 01 00 0C ............
com.serotonin.messaging.WaitingRoomException: No recipient was found waiting for response for key com.serotonin.modbus4j.ip.xa.XaWaitingRoomKey@8008
at com.serotonin.messaging.WaitingRoom.response(WaitingRoom.java:69)
at com.serotonin.messaging.MessageControl.data(MessageControl.java:153)
at com.serotonin.messaging.InputStreamListener.run(InputStreamListener.java:76)
at java.lang.Thread.run(Thread.java:595)
response:
00 00 00 00 00 1B 03 03 18 43 67 12 25 00 00 00 .........Cg.%...
00 00 00 00 00 43 67 12 25 00 00 00 00 43 67 12 .....Cg.%....Cg.
25 %
{voltage 1=231.07088, voltage 6=231.07088, voltage 4=231.07088, voltage 3=0.0, voltage 2=0.0, voltage 5=0.0}
Source:
package test.sim;
import com.serotonin.modbus4j.BatchRead;
import com.serotonin.modbus4j.BatchResults;
import com.serotonin.modbus4j.ModbusFactory;
import com.serotonin.modbus4j.ModbusLocator;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.code.DataType;
import com.serotonin.modbus4j.code.RegisterRange;
import com.serotonin.modbus4j.ip.IpParameters;
public class BatchTest
{
public static void main(String[] args) throws Exception {
IpParameters tcpParameters = new IpParameters();
tcpParameters.setHost("10.17.175.43");
ModbusFactory modbusFactory = new ModbusFactory();
ModbusMaster master = modbusFactory.createTcpMaster(tcpParameters, true);
// master.setTimeout(5000);
for(int i = 0; i < 50; i++) {
try {
BatchRead<String> batchRead = new BatchRead<String>();
int slaveId = 3;
ModbusLocator locator = new ModbusLocator(slaveId, RegisterRange.HOLDING_REGISTER, 1,
DataType.FOUR_BYTE_FLOAT);
ModbusLocator locator2 = new ModbusLocator(slaveId, RegisterRange.HOLDING_REGISTER, 3,
DataType.FOUR_BYTE_FLOAT);
ModbusLocator locator3 = new ModbusLocator(slaveId, RegisterRange.HOLDING_REGISTER, 5,
DataType.FOUR_BYTE_FLOAT);
ModbusLocator locator4 = new ModbusLocator(slaveId, RegisterRange.HOLDING_REGISTER, 7,
DataType.FOUR_BYTE_FLOAT);
ModbusLocator locator5 = new ModbusLocator(slaveId, RegisterRange.HOLDING_REGISTER, 9,
DataType.FOUR_BYTE_FLOAT);
ModbusLocator locator6 = new ModbusLocator(slaveId, RegisterRange.HOLDING_REGISTER, 11,
DataType.FOUR_BYTE_FLOAT);
batchRead.addLocator("voltage 1", locator);
batchRead.addLocator("voltage 2", locator2);
batchRead.addLocator("voltage 3", locator3);
batchRead.addLocator("voltage 4", locator4);
batchRead.addLocator("voltage 5", locator5);
batchRead.addLocator("voltage 6", locator6);
master.init();
BatchResults<String> results = master.send(batchRead);
System.err.println(results);
}
finally {
master.destroy();
}
}
}
}
Thanking you in anticipation!