Wyrm.ModBusClient 1.1.0

There is a newer version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Wyrm.ModBusClient" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Wyrm.ModBusClient" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Wyrm.ModBusClient" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Wyrm.ModBusClient --version 1.1.0
                    
#r "nuget: Wyrm.ModBusClient, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Wyrm.ModBusClient@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Wyrm.ModBusClient&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Wyrm.ModBusClient&version=1.1.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
1.6.0 187 7/17/2026
1.5.0 121 7/4/2026
1.4.0 129 7/3/2026
1.3.1 117 6/30/2026
1.3.0 116 5/30/2026
1.2.0 117 5/22/2026
1.1.0 115 5/22/2026
1.0.0 123 5/10/2026