steveohara / j2mod

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

ReadRequest #101

Closed YaoChiXiaoMi closed 3 years ago

YaoChiXiaoMi commented 5 years ago

I found this problem after using j2mod for a while.The program that collects modbus serial data runs for a while.

Occasionally such a phenomenon(It can happen in a few months): The hexadecimal data sent and the hexadecimal data received are in compliance with the modbus protocol. However, the read data method of j2mod.jar, such as ReadInputRegistersRequest/ReadMultipleRegistersRequest, will report an exception. So that data cannot be collected normally,At this time, you need to re-initialize the ModbusTransaction to reacquire the data.

So, have you discovered this problem before? And has the latest j2mod version been fixed? Can you tell me what to do to avoid this problem? system:Windows2012 Serial port:Virtual serial port j2mod version:2.5.4

steveohara commented 5 years ago

I can't say that I've seen this issue reported. To be honest, good practise would be to capture the exception and then re-establish the connection. Can you at least send me the exception you are seeing?

YaoChiXiaoMi commented 5 years ago

Ok, I will send you the relevant information about the error after the next time this happens again.

YaoChiXiaoMi commented 4 years ago

Last night, I had the problem I told you last time. Because I am a virtual serial port on the cloud server, the data frame is transmitted through the tcp connection. and then last night, the tcpserver on the cloud server is abnormally connected, and then receives abnormal data frames continuously. Just like the picture below

Then the j2mod java package reported a CRC check error, which is understandable, after all, the data frame is wrong.

But after I made a restriction on the connection, I have filtered the exception tcp connection and kept only my modbus device connected, which is the same packet CRC check error, even though the data frame reply is correct every time. Just like the picture below

All I guess is that after receiving some kind of abnormal data frame, it triggers a bug in the CRC always check error under certain conditions. And if I reinitialize the acquisition process at this point, then everything is fine. Just like the picture below

------------------ 原始邮件 ------------------ 发件人: "steveohara"notifications@github.com; 发送时间: 2019年9月2日(星期一) 下午3:39 收件人: "steveohara/j2mod"j2mod@noreply.github.com; 抄送: "e"1107313968@qq.com;"Author"author@noreply.github.com; 主题: Re: [steveohara/j2mod] ReadRequest (#101)

I can't say that I've seen this issue reported. To be honest, good practise would be to capture the exception and then re-establish the connection. Can you at least send me the exception you are seeing?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

steveohara commented 3 years ago

I'm going to close this on the basis that there is a proper workaround for re-establishing a connection and I haven't got any further reports of any issues