Apollo3zehn / FluentModbus

Lightweight and fast client and server implementation of the Modbus protocol (TCP/RTU).
MIT License
188 stars 69 forks source link

ReadHoldingRegistersAsync() does not work properly #104

Open MichaelHoffmeisterFesto opened 6 months ago

MichaelHoffmeisterFesto commented 6 months ago

Hello, I have a code working with the synchronous version of your lib very fine. E.g.:

byte[] id = (Client.ReadHoldingRegisters<byte>(99, address, 2 * quantity)).ToArray();

for address == 1, quantity == 2 is returning good values. When I start the async version of the call, the awaiter is blocking. Only when I am stopping the connection, I get exceptions that the function code was not correct and the call is return e.g. 17 bytes. Any ideas? Best, Michael

Apollo3zehn commented 6 months ago

This should not happen of course but it is difficult to tell what the reason could be. The async code is very similar to the synchronous one. In fact it is being autogenerated by taking the synchronous code and modifying it slightly to prepare it for async operation: https://github.com/Apollo3zehn/FluentModbus/blob/master/src/FluentModbus/Client/ModbusTcpClientAsync.tt

In any case this lib should be easy to debug as nothing fancy is happening internally.