Wyrm.ModBusClient
1.1.0
See the version list below for details.
dotnet add package Wyrm.ModBusClient --version 1.1.0
NuGet\Install-Package Wyrm.ModBusClient -Version 1.1.0
<PackageReference Include="Wyrm.ModBusClient" Version="1.1.0" />
<PackageVersion Include="Wyrm.ModBusClient" Version="1.1.0" />
<PackageReference Include="Wyrm.ModBusClient" />
paket add Wyrm.ModBusClient --version 1.1.0
#r "nuget: Wyrm.ModBusClient, 1.1.0"
#:package Wyrm.ModBusClient@1.1.0
#addin nuget:?package=Wyrm.ModBusClient&version=1.1.0
#tool nuget:?package=Wyrm.ModBusClient&version=1.1.0
Wyrm.ModBusClient
A .Net TCP ModBus client library.
Usage
Add the ModBus client into dependency injection using the AddModBusClient extension method.
using Wyrm.ModBusClient.DependencyInjection;
...
services.AddModBusClient();
By default, it is added as a Singleton but you can specify the lifetime.
services.AddModBusClient(ServiceLifetime.Scoped);
Then inject the IModBusClient interface into your class.
Call ConnectAsync before calling any of the ModBus methods. Although the client can remain connected, it's better to connect, perform the function or functions, and then close it. You can connect the client again after closing it. Make sure you dispose of the client when finished with it.
Functions
Only the TCP specific functions have been implemented. You can set the Unit Identifier before calling any function (it will keep the value set for subsequent functions).
await _modBusClient.ConnectAsync(endPoint, ct);
...
_modBusClient.UnitIdentifier = 0xFF;
var coils = await _modBusClient.ReadCoilsAsync(1, 5, ct);
...
_modBusClient.Close();
You can also set the Transaction Id before calling any function. The Transaction Id increments after each function is called so if you need it to always be a specific value then you need to set it before calling a function.
await _modBusClient.ConnectAsync(endPoint, ct);
...
_modBusClient.TransactionId = 0x5959;
var coils = await _modBusClient.ReadCoilsAsync(1, 5, ct);
...
_modBusClient.Close();
It is also possible to set the Protocol Identifier (for subsequent functions). Usually this is always 0, but certain vendors may require a different number.
await _modBusClient.ConnectAsync(endPoint, ct);
_modBusClient.ProtocolIdentifier = 1;
...
_modBusClient.Close();
Implemented Functions
| Function |
|---|
| ReadCoilsAsync |
| ReadDiscreteInputsAsync |
| ReadHoldingRegistersAsync |
| ReadInputRegistersAsync |
| WriteSingleCoilAsync |
| WriteSingleRegisterAsync |
| WriteMultipleCoilsAsync |
| WriteMultipleRegistersAsync |
| ReadFileRecordAsync |
| WriteFileRecordAsync |
| MaskWriteRegisterAsync |
| ReadWriteMultipleRegistersAsync |
| ReadFifoQueueAsync |
| ReadDeviceIdentifierAsync |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Wyrm.ModBusClient:
| Package | Downloads |
|---|---|
|
Wyrm.ModBusClient.GivEnergy
A TCP ModBus client for GivEnergy inverters. |
GitHub repositories
This package is not used by any popular GitHub repositories.