steveohara / j2mod

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

Error in ReadInputDiscretesRequest class SetBitCount() method. Can't access the last address. #87

Closed mhjohans closed 6 years ago

mhjohans commented 6 years ago

Expected Behavior

It should be possible to create a new ReadInputDiscretesRequest spanning the last possible address (65535).

Actual Behavior

java.lang.IllegalArgumentException at com.ghgande.j2mod.modbus.msg.ReadInputDiscretesRequest.setBitCount(ReadInputDiscretesRequest.java:151)

The SetBitCount() method does this comparison: count + reference >= 65536. It should be changed to: count + reference > 65536.

Steps to Reproduce the Problem

  1. Try to create a new ReadInputDiscretesRequest spanning the last possible address (65535)
  2. FAIL!
steveohara commented 6 years ago

Added fix to snapshot