MangoAutomation / modbus4j

A high-performance and ease-of-use implementation of the Modbus protocol written in Java. Supports ASCII, RTU, TCP, and UDP transports as slave or master, automatic request partitioning and response data type parsing.
GNU General Public License v3.0
897 stars 370 forks source link

validateResponse,check if the request slaveid equal response slaveid #27

Closed ghost closed 5 years ago

terrypacker commented 5 years ago

@minghu, thanks that is much easier. I have a few questions for you:

  1. What is your use case, why do you need this feature?

  2. Have you tested this on TCP or just Serial? We have had a discussion and are concerned that with TCP this may cause issues but are not 100% sure.

Thanks again for your contributions.

ghost commented 5 years ago

in normal condition,below ok 图片 but in some rs485 serial Communication bad condition,its below. 图片 crc is ok,but slave id wrong。i have tested with serial,and tcp Communication don't arise this error.above just one sample,even i can set a long timeout to avoid this error ,but this will effect all datasource,validate is a choice。

terrypacker commented 5 years ago

Thanks, I'm going to pull that in and make some changes so it can be configurable.

terrypacker commented 5 years ago

@minghu FYI here are my changes on this to make it optional and default to using in serial situations: https://github.com/infiniteautomation/modbus4j/commit/f622c6019e54cb86c28bcd7759891fb7622f4638