WriteMultipleRegister does not work
Brought to you by:
wimpi
WriteMultipleRegister fails with
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read
(SocketInputStream.java:195)
at java.io.BufferedInputStream.fill
(BufferedInputStream.java:200)
at java.io.BufferedInputStream.read1
(BufferedInputStream.java:239)
at java.io.BufferedInputStream.read
(BufferedInputStream.java:294)
at java.io.DataInputStream.read
(DataInputStream.java:251)
at
net.wimpi.modbus.io.ModbusTCPTransport.readResponse
(ModbusTCPTransport.java:99)
at
net.wimpi.modbus.io.ModbusTCPTransaction.execute
(ModbusTCPTransaction.java:192)
at
com.mostartech.jamod.util.HModbusHelper.writeMultipleR
egistersSyn(HModbusHelper.java:122)
WriteSingleRegister works properly
Logged In: YES
user_id=1645965
Originator: NO
I think that is a probleme to the jvm 1.5 (i don't have test the 1.4, i suppose it), because in the readData(DataInput din) methode of the WriteMultipleRegister classe, if you replace a line :
int wc = din.readUnsignedShort();
by the lines :
int nbElement = din.readUnsignedShort();
int wc = ((nbElement * 2) / 2);
the WriteMultipleRegister class works.
Logged In: NO
It's fixed in the latest version in CVS.
Logged In: YES
user_id=36782
Originator: NO
I think it should properly work against the DataInput API public final int readUnsignedShort(); The specification says that it uses the following transform:
(((a & 0xff) << 8) | (b & 0xff))
The Modbus Specification states that the quantity should be from 0x0001 to 0x0078 (around 120 registers) I think that the transform should return the right values.
There was a problem with the lengths, but I think as far as that one goes, we are looking at a duplicate report (e.g. was fixed in HEAD).