Fixed dispose on servers

This commit is contained in:
2024-04-21 00:18:28 +02:00
parent bc3ca4fa52
commit 2580554bb1
4 changed files with 31 additions and 1 deletions

View File

@@ -193,6 +193,8 @@ namespace AMWD.Protocols.Modbus.Tcp
_clients.Clear();
_devices.Clear();
_stopCts?.Dispose();
}
private void Assertions()

View File

@@ -23,6 +23,18 @@ float voltage = registers.GetSingle();
Console.WriteLine($"The voltage of device #{unitId} between L1 and N is: {voltage:N2}V");
```
If you want to use the `RTU over TCP` protocol instead, you can do this on initialization:
```csharp
// [...]
using var client = new ModbusTcpClient(host, port)
{
Protocol = new RtuOverTcpProtocol();
};
// [...]
```
## Sources