Home / C# / Snap7: an open source Siemens S7 communication library

Snap7: an open source Siemens S7 communication library

In a recent comment i came across Snap7, a new Siemens S7 open source library to communicate with Siemens Plc S7-300, S7-400, S7-1200 and S7-1500.
It supports many languages (C++, C# and more) and it’s multi-platform.
The library can be downloaded from http://snap7.sourceforge.net and the official page of the project is http://www.facebook.com/snap7.project.

UPDATE: if you use C#, check out the C# port of Snap7 library. Sharp7 comes from the same author of Snap7 and is written completely in C# without the need of wrappers. Read the article.

This is how the author, Davide Nardella, presents his work:

Overview

This library is more than just a driver to read and write data from a PLC, the developer called it “suite” because it contains three independent components:

  • Client
  • Server
  • Partner

home_img

Client

The Client, even if it is the most “obvious” component, features some pretty innovative features such as the smart-connect and asynchronous functions that can perform large data transfers in a separate thread.
Also implements some new features like the set / clear of the password, and upload a DB without knowing the size.

Server

The Server allows you to connect an HMI, Scada or Opc Server to your application. It makes see your application as a Siemens CPU (S7315-2PN / DP) and you can go online also with Simatic Manager / TIA Portal, to see directories and system information.
The Server handles up to 1024 clients contemporaries with consistent access to shared data.
Log in implements a circular queue and asynchronous callback to synchronize with the activity of clients.
(note: it is longer what I have written than what is necessary to make it work).

Partner

The Partner implements the architecture peer-to-peer (or client-client according to Siemens).
This component allows you to make the store-on-demand: it is not PC to question in polling the PLC to check if they have data ready, but it’s the PLC that send data when it decide to do so. The PC receives the data in a completely asynchronous callback.
This is typically accomplished through a TCP / IP connection, in our case everything happens by using the robustness of the protocol S7 PLC side.
The functions used are BSend / BRECV and they allow you to transfer up to 64k in the same task.
The use of this component is not easy(because it is not easy the use of the Partners, according to Siemens, however, there is a very detailed guide on how to do it and there are examples ready to use.

Some common features

License:
LGPL V3.0 (you can use Snap7 in your programs without the requirement to distribute the source and without the requirement that your programs are licensed under the same open source).

Supported Architectures:
32/64 bit Intel / AMD for all platforms and languages ​​supported.
32-bit ARM Linux platform, head (examples attached) on:
Raspberry PI
BeagleBoard Black
PcDuino
CubieBoard Dual core.

Supported languages ​​with object oriented wrappers and examples of multiplatform:
Delphi / FreePascal
.NET / MONO (the assembly is in C #)
C / C ++
LabVIEW (there 83 and a dedicated “glue” dll for the use of buffers untyped).

Supported Platforms (with binary libraries distributed):
Windows: from Windows NT 4.0 to 8, except WinCE and Win95 / Me.
Linux (Intel / ARM)
BSD
Solaris 11  

Download and project home

http://snap7.sourceforge.net
http://www.facebook.com/snap7.project

Share Button

Leave a Reply