FluentModbus 1.2.0

There is a newer version of this package available.
See the version list below for details.
Install-Package FluentModbus -Version 1.2.0
dotnet add package FluentModbus --version 1.2.0
<PackageReference Include="FluentModbus" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FluentModbus --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FluentModbus, 1.2.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install FluentModbus as a Cake Addin
#addin nuget:?package=FluentModbus&version=1.2.0

// Install FluentModbus as a Cake Tool
#tool nuget:?package=FluentModbus&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

FluentModbus is a .NET Standard library that provides a Modbus TCP server and client implementation for easy process data exchange. Support for Modbus RTU and ASCII mode is planned for the next major version. Both, the server and the client, implement class 0 and class 1 functions of the specification. Namely, these are:

Class 0:

  • FC03: ReadHoldingRegisters
  • FC16: WriteMultipleRegisters

Class 1:

  • FC01: ReadCoils
  • FC02: ReadDiscreteInputs
  • FC04: ReadInputRegisters
  • FC05: WriteSingleCoil
  • FC06: WriteSingleRegister

Please see the introduction and the sample application, to get started with FluentModbus.

Quick start

Client

var unitIdentifier = (byte)0xFF;
var startingAddress = (ushort)0;
var count = (ushort)10;
var client = new ModbusTcpClient();
var endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 502);

client.Connect(endPoint)

// read data
var shortData = client.ReadHoldingRegisters<short>(unitIdentifier, startingAddress, count);

// write data
var intData = new int[] { 4263, 4554 };
client.WriteMultipleRegisters(unitIdentifier, startingAddress, intData);

Server

var cts = new CancellationTokenSource();
var random = new Random();
var server = new ModbusTcpServer();

server.Start();

while (!cts.IsCancellationRequested)
{
    var intData = server.GetHoldingRegisterBuffer<int>();

    // lock is required to synchronize buffer access between
    // this application and one or more Modbus clients
    lock (server.Lock)
    {
        intData[20] = random.Next(0, 100);
    }

    // update server buffer content only once per second
    Thread.Sleep(TimeSpan.FromSeconds(1));
}

server.Dispose();

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FluentModbus:

Package Downloads
SMAModbusConnector

A Modbus Connector for SMA devices

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.0-preview.1.final 79 9/21/2021
3.2.0 114 9/14/2021
3.1.1 982 6/23/2021
3.1.0 2,230 4/13/2021
3.0.1 298 3/25/2021
3.0.1-preview.1.final 420 2/15/2021
2.4.2 1,437 12/22/2020
2.4.1 385 11/27/2020
2.4.0 242 11/9/2020
2.3.0 345 11/6/2020
2.2.1 363 9/21/2020
2.2.0 227 9/1/2020
2.1.0 187 8/6/2020
2.0.0 2,499 12/9/2019
2.0.0-preview.3.final 157 12/6/2019
2.0.0-preview.2.final 190 12/4/2019
2.0.0-preview.1.final 192 12/4/2019
1.4.1 221 11/23/2019
1.4.0 250 11/17/2019
1.4.0-alpha.1.final 147 11/17/2019
1.3.0 216 11/13/2019
1.2.0 783 5/11/2019