libplctag 2.0.0-alpha.2

This is a prerelease version of libplctag.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package libplctag --version 2.0.0-alpha.2
                    
NuGet\Install-Package libplctag -Version 2.0.0-alpha.2
                    
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="libplctag" Version="2.0.0-alpha.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="libplctag" Version="2.0.0-alpha.2" />
                    
Directory.Packages.props
<PackageReference Include="libplctag" />
                    
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 libplctag --version 2.0.0-alpha.2
                    
#r "nuget: libplctag, 2.0.0-alpha.2"
                    
#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 libplctag@2.0.0-alpha.2
                    
#: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=libplctag&version=2.0.0-alpha.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=libplctag&version=2.0.0-alpha.2&prerelease
                    
Install as a Cake Tool

libplctag.NET

libplctag is a C library for Linux, Android, Windows and macOS that uses EtherNet/IP or Modbus TCP to read and write tags in PLCs.

libplctag.NET provides wrapper packages for libplctag, with an API naturalised to .NET by adding the following features:

  • Values are strongly-typed
  • Errors are thrown as Exceptions
  • Async/Await
  • Native resource cleanup

How to use

// Example tag configuration for a global DINT tag in an Allen-Bradley CompactLogix/ControlLogix PLC
var myTag = new Tag()
{
    Name = "SomeDINT",
    Gateway = "10.10.10.10",
    Path = "1,0",
    PlcType = PlcType.ControlLogix,
    Protocol = Protocol.ab_eip
};

// Read the value from the PLC
myTag.Read();
int originalValue = myTag.GetInt32(0);        
Console.WriteLine($"Original value: {originalValue}");

// Write a new value to the PLC
int updatedValue = 1234;
myTag.SetInt32(0, updatedValue);
myTag.Write();    
Console.WriteLine($"Updated value: {updatedValue}");

To force separate channels to the same PLC from one process, set different ConnectionGroupId values:

var channel1Tag = new Tag()
{
    Name = "SomeDINT",
    Gateway = "10.10.10.10",
    Path = "1,0",
    PlcType = PlcType.ControlLogix,
    Protocol = Protocol.ab_eip,
    ConnectionGroupId = 1
};

var channel2Tag = new Tag()
{
    Name = "SomeOtherDINT",
    Gateway = "10.10.10.10",
    Path = "1,0",
    PlcType = PlcType.ControlLogix,
    Protocol = Protocol.ab_eip,
    ConnectionGroupId = 2
};

If ConnectionGroupId is not set, the channel is shared.

See the examples projects for further detail and usage:

Introduction

A tag is a local reference to a region of PLC memory. Depending on the PLC type and protocol the region may be named. For some protocols, the region is simply a type and register number (e.g. Modbus). For other protocols, it is a name, possible array element, field names etc. (e.g. a CIP-based PLC).

Your program directly controls the resources associated with the connection to the PLC. It initializes these resources through the Initialize() function and frees the resources used with the Dispose() function. The lowest level of access to a tag is via the Read() and Write() operations. In most cases you must explicitly call these functions to write to the PLC or read from the PLC. There are also attributes that can be passed when creating a Tag to make it either automatically write to the PLC when the local copy of the tag is updated or read from the PLC periodically, or both. Once initialized, the tag memory is exposed as a byte array, and can be manipulated using various data accessors.

Libplctag does not expose the concept of a PLC. Just tags.

Read more on the libplctag wiki.

libplctag.Tag

libplctag.NET provides a wrapper for the C API naturalised for .NET. The Tag class is intended to be functionally equivalent to the C API.

For example:

Some methods are presented slightly differently due to the differences in languages and language idioms. For example, the counterpart to Initialize(..) is plc_tag_create(..) and the tag attributes are specified as properties (e.g. Tag.Path).

Data Accessors

Mapping the raw tag buffer to some typed value (e.g. int) and vice-versa can be achieved using the built-in Data Accessor methods. Alternatively, get a copy of the byte array with GetBuffer(..) and do the conversion yourself (e.g. with BitConverter, BinaryPrimities, Encoding, or manually).

In general, you will need prior knowedge of the binary format of the tag data, and you may need to reverse-engineer it. The manuals provided by your device manufacturer are the best source of information on these details.

libplctag.LibPlcTag

This is a static class used to access some utility features of the libplctag base library such as global debug levels and logging.

libplctag.NativeImport

The libplctag package depends on the core libplctag libraries which are written in C and are released as native binaries. The delivery of these files, and the interop to the .NET environment is provided by the libplctag.NativeImport package.

Information on this package can be found here.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on libplctag:

Package Downloads
CeriL2Lib

冶金行业L2类库

MgSoftDev.IndustrialController.AllenBradley.LibPlcTagNetCore

Allen Bradley and Omron provider for MgSoftDev.IndustrialController, built on the open source libplctag driver over EtherNet/IP (port 44818). Supports ControlLogix, CompactLogix, PLC-5, SLC 500, Micro800, MicroLogix and Omron NJ/NX. This is the recommended provider for .NET 7+ - it needs no commercial license. Note: its runtime namespace is IndustrialController.AllenBradley.LibPlcTagNetCore, without the MgSoftDev prefix.

clxx.libplctag.NET

A high level API for reading/writing tags to Rockwell CLX PLCs. ControlLogix and CompactLogix.

PlcCipTag

CIP protocol Tag-based PLC communication library supporting Allen-Bradley, ICON, and Omron PLCs via EtherNet/IP.

ZL.IotOss

ZL.IotEngine 的开源驱动适配包:S7.Net Plus(西门子)/ NModbus 3.x(Modbus TCP/RTU/ASCII)/ LibPlcTag(AB EtherNet/IP:ControlLogix/CompactLogix/Micro800/MicroLogix/PLC-5/SLC500;Omron NJ/NX CIP/EtherNet/IP,PlcType 选择)。只依赖 ZL.IotEngine 的契约面,不依赖 ZL.IotDriver。零自研、全开源、避免收费。范围说明:不含三菱 MC(libplctag 不支持 MC 协议,经证据评审按「宁缺毋滥」排除,见 docs/573)。示例见 https://github.com/qwdingyu/ZL.IotHubDemo 。

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on libplctag:

Repository Stars
OPCFoundation/UA-EdgeTranslator
An industrial connectivity edge application translating from proprietary protocols to OPC UA leveraging the W3C Web of Things (WoT) thing descriptions.
Version Downloads Last Updated
2.0.0-alpha.5 77 11/24/2026
2.0.0-alpha.4 158 11/17/2026
2.0.0-alpha.3 89 11/17/2026
2.0.0-alpha.2 77 11/15/2026
2.0.0-alpha.1 85 11/15/2026
1.6.0 813 11/20/2026
1.6.0-rc.1 89 11/15/2026
1.6.0-alpha.5 25,568 7/20/2025
1.6.0-alpha.4 8,695 2/1/2025
1.6.0-alpha.3 217 1/29/2025
1.6.0-alpha.2 186 1/14/2025
1.6.0-alpha.1 223 1/1/2025
1.6.0-alpha.0 3,174 7/26/2024
1.5.2 182,254 7/13/2024
1.5.1 2,063 7/12/2024
1.5.0 601 7/12/2024
1.4.1 1,886 6/22/2024
1.4.0 675 6/15/2024
1.3.1 273 6/15/2024
1.3.0 2,024 6/15/2024
Loading failed