steveohara / j2mod

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

Add delay before read response in to Serial #95

Closed leganas closed 5 years ago

leganas commented 5 years ago

Description of the problem There is a problem when reading the answer on some SerialPort devices. Calling the execute () method causes the reading to fail by mistake "ModbusSerialMaster I/O exception - failed to read response for request"

Proposed Solution Add a delay between sending the request and reading the response

Specifications Version: 2.5.4-SNAPSHOT

steveohara commented 5 years ago

There is already a mechanism for doing this that gives you a bit more control. Take a look at addListener/removeListener and AbstractSerialTransportListener. This will call back when events occur on the serial transport so that you can inject delays etc.

leganas commented 5 years ago

Thanks for the advice, in that case my pull request is redundant