FluentModbus icon indicating copy to clipboard operation
FluentModbus copied to clipboard

Timeout Exception on Linux in 4.0.0-preview1

Open aviatrix opened this issue 3 years ago • 4 comments

When testing the preview1 version of the package, we encountered a bug where the client times out after first read from RTU server, which was no the behavior we had on the code of my version of the PR, so this makes me thing something broke in the new version, but i don't see anything that could break it and just on Linux for that matter.

Any help or hints would be appreciated

aviatrix avatar Oct 01 '21 07:10 aviatrix

Thanks for your feedback! I'll test it on Monday when I have access to a Linux machine.

Apollo3zehn avatar Oct 01 '21 07:10 Apollo3zehn

The Parity Default is Parity.Even , some device don't support it , so we got a Timeout Exception ! if modify Parity.Even to Parity.None , we got Modbus_NoParityRequiresTwoStopBits so remove
if (this.Parity == Parity.None && this.StopBits != StopBits.Two) throw new InvalidOperationException(ErrorMessage.Modbus_NoParityRequiresTwoStopBits);

https://github.com/Apollo3zehn/FluentModbus/pull/56

maikebing avatar Oct 01 '21 08:10 maikebing

According to the spec (https://www.modbus.org/docs/Modbus_over_serial_line_V1_02.pdf), section 2.5.1 RTU Transmission Mode:

  • "The default parity mode must be even parity."
  • "... the use of no parity requires 2 stop bits."

So I think the devices are not working according to the Modbus specification. I will remove the error message to allow compatibility, but the default of the parity mode should be kept even to stay in line with the spec.

Edit: sorry I wanted to post this to the pull request thread.

Apollo3zehn avatar Oct 19 '21 07:10 Apollo3zehn

@aviatrix I have removed the InvalidOperationException as maikebing proposed in his pull request. But I guess you problem is different, isn't it?

Apollo3zehn avatar Oct 19 '21 08:10 Apollo3zehn