libplctag 2.0.0-alpha.2
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
<PackageReference Include="libplctag" Version="2.0.0-alpha.2" />
<PackageVersion Include="libplctag" Version="2.0.0-alpha.2" />
<PackageReference Include="libplctag" />
paket add libplctag --version 2.0.0-alpha.2
#r "nuget: libplctag, 2.0.0-alpha.2"
#:package libplctag@2.0.0-alpha.2
#addin nuget:?package=libplctag&version=2.0.0-alpha.2&prerelease
#tool nuget:?package=libplctag&version=2.0.0-alpha.2&prerelease
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:
Read(..)≋plc_tag_read(..)Write(..)≋plc_tag_write(..)GetInt32(..)≋plc_tag_get_int32(..)
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 | Versions 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. |
-
.NETStandard 2.0
- libplctag.NativeImport (>= 2.0.0-alpha.10)
-
net10.0
- libplctag.NativeImport (>= 2.0.0-alpha.10)
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 |