PPI
Serial PPI transport and client support for S7-200 PLCs. Install the optional
dependency with pip install "python-snap7[ppi]" and see S7-200 Serial PPI for
setup, area semantics, and current limitations.
Siemens S7-200 PPI serial transport and client.
PPI carries ordinary S7 PDUs inside PROFIBUS-style SD1/SD2 frames. The implementation follows the request/acknowledgement exchange used by libnodave: an SD2 request, an E5 acknowledgement, an SD1 request-data poll, and an SD2 response.
- class snap7.ppi.PPIClient(port: str, *, station: int = 2, local_station: int = 0, baudrate: int = 9600, timeout: float = 0.15, transport: PPIExchangeTransport | None = None)[source]
Bases:
objectMinimal S7-200 client using PPI over a serial port.
- read_area(area: PPIArea, start: int, count: int) bytearray[source]
Read items from an S7-200 memory area.
countis bytes for S/SM/I/Q/M/V and 16-bit items for AI/AQ/C/T.
- class snap7.ppi.PPIExchangeTransport(*args, **kwargs)[source]
Bases:
ProtocolTransport interface consumed by
PPIClient.
- class snap7.ppi.PPIFrame(frame_type: PPIFrameType, destination: int | None = None, source: int | None = None, control: int | None = None, payload: bytes = b'')[source]
Bases:
objectDecoded PPI frame.
- class snap7.ppi.PPITransport(port: str, *, station: int = 2, local_station: int = 0, baudrate: int = 9600, timeout: float = 0.15, retries: int = 3, serial_port: SerialPort | None = None)[source]
Bases:
objectSerial PPI master transport for a single S7-200 slave.
- class snap7.ppi.SerialPort(*args, **kwargs)[source]
Bases:
ProtocolMinimal serial-port interface used by
PPITransport.
- snap7.ppi.encode_sd1(destination: int, source: int, control: int) bytes[source]
Encode a fixed-length SD1 frame.