Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DetectResponseFrame failed #83

Closed
zhangchaoza opened this issue Nov 15, 2022 · 4 comments
Closed

DetectResponseFrame failed #83

zhangchaoza opened this issue Nov 15, 2022 · 4 comments

Comments

@zhangchaoza
Copy link

ModbusClient call WriteSingleCoilAsync or WriteSingleRegisterAsync timeout when registerAddress over 1023. Test code as as follows:

var client = new ModbusRtuClient()
{
    BaudRate = 115200,
    Parity = System.IO.Ports.Parity.None,
    StopBits = System.IO.Ports.StopBits.One,
    ReadTimeout = 3000,
};
client.Connect("COM7", ModbusEndianness.BigEndian);
await client.WriteSingleCoilAsync(1, 0x03FF, true); // write Coil address of 1023
await client.WriteSingleCoilAsync(1, 0x0400, true); // write Coil address of 1024 timeout
await client.WriteSingleRegisterAsync(1, 0x03FF, 1);// write reg address of 1023
await client.WriteSingleRegisterAsync(1, 0x0400, 1);// write reg address of 1024 timeout

output:

Unhandled exception. System.TimeoutException: The asynchronous read operation timed out.
   at FluentModbus.ModbusRtuSerialPort.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken token) in /home/runner/work/FluentModbus/FluentModbus/src/FluentModbus/ModbusRtuSerialPort.cs:line 107
   at FluentModbus.ModbusRtuClient.TransceiveFrameAsync(Byte unitIdentifier, ModbusFunctionCode functionCode, Action`1 extendFrame, CancellationToken cancellationToken) in /home/runner/work/FluentModbus/FluentModbus/src/FluentModbus/Client/ModbusRtuClientAsync.cs:line 58
   at FluentModbus.ModbusClient.WriteSingleCoilAsync(Int32 unitIdentifier, Int32 registerAddress, Boolean value, CancellationToken cancellationToken) in /home/runner/work/FluentModbus/FluentModbus/src/FluentModbus/Client/ModbusClientAsync.cs:line 267

And the Modbus Slave software logs as follows:

Rx:000145-01 05 03 FF FF 00 BC 4E 
Tx:000146-01 05 03 FF FF 00 BC 4E 
Rx:000147-01 05 04 00 FF 00 8D 0A 
Tx:000148-01 05 04 00 FF 00 8D 0A 
Rx:000157-01 06 03 FF 00 01 78 7E 
Tx:000158-01 06 03 FF 00 01 78 7E 
Rx:000159-01 06 04 00 00 01 49 3A 
Tx:000160-01 06 04 00 00 01 49 3A 

I found that DetectResponseFrame method will always return false when detect 01 05 04 00 FF 00 8D 0A.

@Apollo3zehn
Copy link
Owner

Apollo3zehn commented Nov 17, 2022

Thank you - the DetectResponse frame implementation seems to be incorrect for "write single"-methods. I´ll publish an update now.

@Apollo3zehn
Copy link
Owner

Should be solved now with v5.0.2. Unfortunately I still have not good Modbus RTU test setup so I would be glad if you can confirm that the bug does not appear any longer.

@zhangchaoza
Copy link
Author

Yes it works fine and thank you

@JohnMasen
Copy link

just about to raise this issue.
After upgrade to 5.0.2, I ran my tests and it is confirmed that the issue is fixed.
Thank you guys, very appeaciated for your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants