
Sharp7
Reference manual
Davide Nardella
Rev.1 – October 7, 2016

P a g e | 2
Sharp7 1.0.0 - Reference manual
P a g e | 2
Sharp7 1.0.0 - Reference manual
Summary
Summary ............................................................................................................... 2
Project overview ...................................................................................................... 4
Main features .......................................................................................................... 4
Licensing ................................................................................................................ 5
Disclaimer of Warranty ............................................................................................. 5
About this manual ................................................................................................... 6
Siemens S7 Protocol ................................................................................................ 7
Compatibility........................................................................................................... 9
S7 300/400/WinAC ................................................................................................ 10
S7 1200/1500 ....................................................................................................... 11
LOGO! 0BA7/0BA8 ................................................................................................. 13
S7 200 (via CP243)................................................................................................ 17
Sharp7 deploy ....................................................................................................... 19
S7Client reference ................................................................................................. 20
Administrative functions ......................................................................................... 20
SetConnectionType ............................................................................................ 21
ConnectTo ........................................................................................................ 22
SetConnectionParams ........................................................................................ 24
Connect ............................................................................................................ 25
Disconnect ........................................................................................................ 26
Base Data I/O functions ......................................................................................... 27
ReadArea .......................................................................................................... 28
WriteArea ......................................................................................................... 30
ReadMultiVars ................................................................................................... 31
WriteMultiVars ................................................................................................... 32
Lean Data I/O functions ......................................................................................... 33
Block oriented functions ......................................................................................... 34
GetAgBlockInfo ................................................................................................. 35
DBGet .............................................................................................................. 37
DBFill .............................................................................................................. 38
Date/Time functions ............................................................................................... 39
GetPlcDateTime ................................................................................................. 40
SetPlcDateTime ................................................................................................. 41
SetPlcSystemDateTime ....................................................................................... 42
System info functions ............................................................................................. 43
ReadSZL ........................................................................................................... 44

P a g e | 3
Sharp7 1.0.0 - Reference manual
P a g e | 3
Sharp7 1.0.0 - Reference manual
GetOrderCode ................................................................................................... 45
GetCpuInfo ....................................................................................................... 46
GetCpInfo ......................................................................................................... 47
PLC control functions ............................................................................................. 48
PlcColdStart ...................................................................................................... 49
PlcHotStart ....................................................................................................... 50
PlcStop ............................................................................................................. 51
PlcGetStatus ..................................................................................................... 52
Security functions .................................................................................................. 53
SetSessionPassword ........................................................................................... 54
ClearSessionPassword ........................................................................................ 55
GetProtection .................................................................................................... 56
Properties/Info Functions ........................................................................................ 57
ConnTimeout..................................................................................................... 57
RecvTimeout ..................................................................................................... 57
SendTimeout ..................................................................................................... 57
Connected ........................................................................................................ 57
PduSizeNegotiated ............................................................................................. 57
PduSizeRequested ............................................................................................. 57
PLCPort ............................................................................................................ 57
ExecutionTime ................................................................................................... 57
S7 Helper reference ............................................................................................... 58
Data access example ............................................................................................. 59
S7MultiVar reference .............................................................................................. 61
Error codes ........................................................................................................... 62

P a g e | 4
Sharp7 1.0.0 - Reference manual
P a g e | 4
Sharp7 1.0.0 - Reference manual
Project overview
Sharp7 is the C# port of Snap7 Client. It’s not a wrapper, i.e. you don’t have an
interface code that loads snap7.dll (or .so) but it’s a pure C# implementation of the
S7Protocol.
Sharp7 is deployed as a single source file that contains some classes that you can use
directly in your .NET project to communicate with S7 PLCs.
It’s designed to work with small hardware .NET-based or even for large projects which
don’t needs of extended control functions.
Main features
Fully standard “safe managed” C# code without any dependencies.
Virtually every hardware with an Ethernet adapter able to run a .NET Core can be
connected to an S7 PLC.
Packed protocol headers to improve performances.
Helper class to access to all S7 types without worrying about Little-Big endian
conversion.
Compatible with Universal Windows Platform including Win10 IoT for Raspberry.
One single file.
Compatible with Snap7.net.cs, plug and play replaceable.
No additional libraries to deploy.

P a g e | 5
Sharp7 1.0.0 - Reference manual
P a g e | 5
Sharp7 1.0.0 - Reference manual
Licensing
Sharp7 is distributed as a source code library under GNU Library or Lesser General
Public License version 3.0 (LGPLv3).
Basically this means that you can distribute your commercial firmware containing
Sharp7 without the requirement to distribute the source code of your application and
without the requirement that your firmware be itself distributed under LGPL. A small
mention is however appreciated if you include it in your applications.
Disclaimer of Warranty
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF
THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU
ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
IF ANYONE BELIEVES THAT, WITH SHARP7 PROJECT HAVE BEEN VIOLATED SOME
COPYRIGHTS, PLEASE EMAIL US, AND ALL THE NECESSARY CHANGES WILL BE MADE.