If you just need a quick server with some default values initalised, this package provides a default implementation. To use it you first need to install some aditional dependencies, using:

pip install python-snap7[cli]

Now you can start it using one of the following commands:

python -m snap7.server
# or, if your Python `Scripts/` folder is on PATH:

You can optionally provide the port to be used as an argument, like this:

python -m snap7.server --port 102

Snap7 server used for mimicking a siemens 7 server.

class snap7.server.Server(log: bool = True)[source]

A fake S7 server.

__init__(log: bool = True)[source]
Create a fake S7 server. set log to false if you want to disable
event logging to python logging.
Parameters:logTrue for enabling the event logging. Optinoal.

Create the server.


Destroy the server.

event_text(event: snap7.types.SrvEvent) → str[source]

Returns a textual explanation of a given event object

Parameters:event – an PSrvEvent struct object
Returns:The error string
get_mask(kind: int) → ctypes.c_uint[source]

Reads the specified filter mask.

get_param(number) → int[source]

Reads an internal Server object parameter.

Parameters:number – number of the parameter to be set.
Returns:Value of the parameter.
get_status() → Tuple[str, str, int][source]
Reads the server status, the Virtual CPU status and the number of
the clients connected.
Returns:Server status, cpu status, client count
pick_event() → Optional[snap7.types.SrvEvent][source]

Extracts an event (if available) from the Events queue.

Returns:Server event.

Parses a s7 error code returned the decorated function.

snap7.server.mainloop(tcpport: int = 1102, init_standard_values: bool = False)[source]

Init a fake Snap7 server with some default values.

  • tcpport – port that the server will listen.
  • init_standard_values – if True will init some defaults values to be read on DB0.