steveohara / j2mod

Enhanced Modbus library implemented in the Java programming language
Apache License 2.0
267 stars 111 forks source link

WriteMultipleRegisters (Function Code : 0x10) does not work. #14

Closed nices96 closed 8 years ago

nices96 commented 8 years ago

I created a mockup modbus slave(TCP Server) using ModbusTCPListener class and test WriteMultipleRegisters function, but error occurred with "Illegal Data Address" message.

I think it is problem with WriteMultipleRegistersRequest.readData()'s _m_Reference = input.readShort();_.

I changed to input.readUnsignedShort() and checked it works fine.

steveohara commented 8 years ago

I added a test case for this and it works OK - are you using a register number over 32767?

steveohara commented 8 years ago

Added fixes for this and other places where the library should be using unsigned shorts The latest snapshot has the fixes - could you let me know if you see any issues https://oss.sonatype.org/content/repositories/snapshots/com/ghgande/j2mod/2.0-SNAPSHOT/j2mod-2.0-20160429.141401-1.jar

nices96 commented 8 years ago

Yes, I did use over 40000 as a register number. Thanks.