Inetkid.Modbus 1.1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Inetkid.Modbus --version 1.1.0.4                
NuGet\Install-Package Inetkid.Modbus -Version 1.1.0.4                
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="Inetkid.Modbus" Version="1.1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Inetkid.Modbus --version 1.1.0.4                
#r "nuget: Inetkid.Modbus, 1.1.0.4"                
#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.
// Install Inetkid.Modbus as a Cake Addin
#addin nuget:?package=Inetkid.Modbus&version=1.1.0.4

// Install Inetkid.Modbus as a Cake Tool
#tool nuget:?package=Inetkid.Modbus&version=1.1.0.4                

Modbus Library

Modbus library for communication via RS-485 and TCP/IP. Very light and hackable. Support Modbus RTU, Modbus ASCII, Modbus TCP transport; and the role of client, server, master, slave, and gateway. Written in Visual Studio 2022 for .net6.

Quick Start

Install

dotnet add package Inetkid.Modbus
dotnet add package Inetkid.Modbus.Rtu
dotnet add package Inetkid.Modbus.Ascii
dotnet add package Inetkid.Modbus.Tcp

Communicating with a modbus device

using System.IO.Ports;
using Inetkid.Modbus.Command;

byte deviceId = 1;
ushort address = 0;
ushort length = 2;
using (SerialPort sp = new("COM1") { ReadTimeout = 500, WriteTimeout = 100 })
{
    // Initialize ModbusCommand to use the modbus RTU protocol
    var command = new ModbusCommand().UseRtu(sp);

    // Set the request content to read the first 2 holding registers (analog output) 
    // and asynchronously execute the command
    var result = command.RequestReadHoldingRegisters(deviceId, address, length).Execute().Result;

    Console.WriteLine("Value at register 400001 is " + result.Registers[0]);
    Console.WriteLine("Value at register 400002 is " + result.Registers[1]);
}

See examples in REFERENCE.md

Emulates a modbus device

See examples in REFERENCE.md

Gateway TCP to RS485

See examples in REFERENCE.md

Creating device specific adaper

See examples in REFERENCE.md

Change Log

2023-05-17 Version 1.1.0.3

Split the functionality of RTU, ASCII and TCP to 3 separate nuget package to optimize the package size.

Changes to the abstract class ModbusAdapter

Bug fixes

For history of changes please refer to the file CHANGELOG.md

Reference

Refer to the file REFERENCE.md

License

Copyright 2023 Raymond Tan.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contributing

You are welcomed to improve the code. Please visit https://gitlab.com/inetkid/inetkid.modbus Targets .net 6 and above. Written in C# for Microsoft Visual Studio 2022.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Inetkid.Modbus:

Package Downloads
Inetkid.Modbus.Rtu

Package Description

Inetkid.Modbus.Tcp

Package Description

Inetkid.Modbus.Ascii

Package Description

Inetkid.Modbus.Server

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0.1 298 1/9/2024
1.2.0 252 1/8/2024
1.1.0.4 221 5/16/2023
1.1.0.3 131 5/16/2023
1.0.0 168 4/19/2023