python-snap7
1.1
  • Introduction
  • Binary Wheel Installation
  • Manual Installation (not recommended)
  • development
  • Client
  • Server
  • Partner
  • Logo
  • Util
python-snap7
  • Docs »
  • Logo
  • Edit on GitHub

Logo¶

class snap7.logo.Logo[source]¶

A snap7 Siemens Logo client: There are two main comfort functions available Logo.read() and Logo.write(). This functions realize a high level access to the VM addresses of the Siemens Logo just use the form:

Notes

V10.3 for bit values V10 for the complete byte VW12 for a word (used for analog values) For more information see examples for Siemens Logo 7 and 8

__init__()[source]¶

Creates a new instance of Logo

connect(ip_address: str, tsap_snap7: int, tsap_logo: int, tcpport: int = 102) → int[source]¶

Connect to a Siemens LOGO server.

Notes

Howto setup Logo communication configuration see: http://snap7.sourceforge.net/logo.html

Parameters:
  • ip_address – IP ip_address of server
  • tsap_snap7 – TSAP SNAP7 Client (e.g. 10.00 = 0x1000)
  • tsap_logo – TSAP Logo Server (e.g. 20.00 = 0x2000)
Returns:

Error code from snap7 library.

create()[source]¶

Create a SNAP7 client.

db_read(db_number: int, start: int, size: int) → bytearray[source]¶

This is a lean function of Cli_ReadArea() to read PLC DB.

Parameters:
  • db_number – for Logo only DB=1
  • start – start address for Logo7 0..951 / Logo8 0..1469
  • size – in bytes
Returns:

Array of bytes

db_write(db_number: int, start: int, data: bytearray) → int[source]¶

Writes to a DB object.

Parameters:
  • db_number – for Logo only DB=1
  • start – start address for Logo7 0..951 / Logo8 0..1469
  • data – bytearray
Returns:

Error code from snap7 library.

destroy() → int[source]¶

Destroy a client.

Returns:Error code from snap7 library.
disconnect() → int[source]¶

Disconnect a client.

Returns:Error code from snap7 library.
get_connected() → bool[source]¶

Returns the connection status

Notes

This function has a bug, that returns True when the connection
is lost. This comes from the original snap7 library.
Returns:True if connected.
get_param(number) → int[source]¶

Reads an internal Logo object parameter.

Parameters:number – Parameter type number
Returns:Parameter value
read(vm_address: str)[source]¶

Reads from VM addresses of Siemens Logo. Examples: read(“V40”) / read(“VW64”) / read(“V10.2”)

Parameters:vm_address – of Logo memory (e.g. V30.1, VW32, V24)
Returns:integer
set_connection_params(ip_address: str, tsap_snap7: int, tsap_logo: int)[source]¶

Sets internally (IP, LocalTSAP, RemoteTSAP) Coordinates.

Notes

This function must be called just before Cli_Connect().

Parameters:
  • ip_address – IP ip_address of server
  • tsap_snap7 – TSAP SNAP7 Client (e.g. 10.00 = 0x1000)
  • tsap_logo – TSAP Logo Server (e.g. 20.00 = 0x2000)
Raises:
  • ValueError – if the ip_address is not an IPV4.
  • Snap7Exception – if the snap7 error code is diferent from 0.
set_connection_type(connection_type: int)[source]¶
Sets the connection resource type, i.e the way in which the Clients
connects to a PLC.
Parameters:connection_type – 1 for PG, 2 for OP, 3 to 10 for S7 Basic
Raises:Snap7Exception – if the snap7 error code is diferent from 0.
set_param(number: int, value)[source]¶

Sets an internal Server object parameter.

Parameters:
  • number – Parameter type number
  • value – Parameter value
Returns:

Error code from snap7 library.

write(vm_address: str, value: int) → int[source]¶

Writes to VM addresses of Siemens Logo.

Parameters:
  • vm_address – write offset
  • value – integer

Examples

>>> write("VW10", 200) or write("V10.3", 1)
Next Previous

© Copyright 2013, Gijs Molenaar, Stephan Preeker Revision d46834fb.

Built with Sphinx using a theme provided by Read the Docs.