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.