TKH.S7Plus.Net 0.4.0

dotnet add package TKH.S7Plus.Net --version 0.4.0
                    
NuGet\Install-Package TKH.S7Plus.Net -Version 0.4.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="TKH.S7Plus.Net" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TKH.S7Plus.Net" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="TKH.S7Plus.Net" />
                    
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 TKH.S7Plus.Net --version 0.4.0
                    
#r "nuget: TKH.S7Plus.Net, 0.4.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 TKH.S7Plus.Net@0.4.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=TKH.S7Plus.Net&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=TKH.S7Plus.Net&version=0.4.0
                    
Install as a Cake Tool

Build Status

S7Plus.Net

S7Plus.NET is a .NET library for communicating with Siemens S7-1200 and S7-1500 PLCs using the extended S7 protocol. The library is based on the excellent work of Thomas Wiens in the S7CommPlusDriver project. (https://github.com/thomas-v2/S7CommPlusDriver)

Installation

The library is available as a NuGet package. You can install it using the following command:

dotnet add package TKH.S7Plus.Net

Usage

Connecting to the PLC

  • Create an instance of the S7Driver and connect to the PLC:

    using TKH.S7Plus.Net;
    using System;
    
    IS7Driver driver = new S7Driver();
    driver.SetTimeout(TimeSpan.FromSeconds(5));
    await driver.Connect("192.168.178.140", 102);
    

Writing Variables

  • Write a boolean variable to the PLC:

    using TKH.S7Plus.Net.Models;
    using TKH.S7Plus.Net.S7Variables;
    
    await driver.SetVariable(new S7AbsoluteAddress(1, 9), new S7VariableBool(true));
    

Reading Variables

  • Read a variable from the PLC using the symbol name:

      List<Datablock> datablocks = await driver.GetDatablocks();
      VariableInfo? variableInfo = await driver.GetVariableInfoBySymbol("DB1.TEST_DINT", datablocks);
      var variableResult = await driver.GetVariable(variableInfo!.Address);
    
  • Read an array variable from the PLC using the symbol name:

      variableInfo = await driver.GetVariableInfoBySymbol("DB1.TEST_ARRAY", datablocks);
      variableResult = await driver.GetVariable(variableInfo!.Address);
      S7VariableDIntArray dintArray = (S7VariableDIntArray)variableResult;
      Console.WriteLine($"Value of DB1.TEST_ARRAY: {string.Join(", ", dintArray.Value)}");
    

Disconnecting from the PLC

  • Disconnect from the PLC:

    driver.Disconnect();
    

Commercially Supported

This library is commercially supported by TKH Software. Don't hesitate contacting us if you're building something large, in need of advice or having other business inquiries in mind.

License

This project is licensed under the LGPL-3.0 License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.0 166 2/10/2025
0.3.2 153 9/6/2024
0.3.1 141 8/26/2024
0.3.0 140 8/23/2024
0.2.1 148 8/20/2024
0.2.0 150 8/20/2024
0.1.0 143 8/15/2024