How hilscherautomation/netpi-openplc works
Project Type & Purpose
• Type: Embedded/edge-focused Docker image packaging an IEC 61131-3 PLC runtime.
• Purpose: Provide a ready-to-run OpenPLC V3 environment on netPI (Raspberry Pi 3B-based) with SSH, web GUI, Modbus TCP and a custom GPIO hardware layer.
File-Structure & README Analysis
– Top‐level files:
• Dockerfile / .dockerignore → container build.
• init.d/entrypoint.sh → container startup.
• hardware_layer/raspberrypi.cpp → custom GPIO interface.
• sample/… → test programs (.st, .xml).
– README highlights:
• Base: Debian + OpenPLC_v3 + SSH + custom hardware layer.
• Runtime exposes ports 22 (SSH), 8080 (GUI), 502 (Modbus TCP).
• Host requirements: privileged mode, /dev/gpiomem device mapping.
• External tools: Portainer UI, PLCOpen Editor, Modbus client.
Main Components
A. Host (netPI device)
– Docker Engine
– /dev/gpiomem (GPIO device)
B. Container (“hilschernetpi/netpi-openplc”)
1. Base OS (Debian)
2. init.d/entrypoint.sh (startup script)
3. SSH Daemon (port 22)
4. OpenPLC Runtime Core
• Webserver (port 8080)
• Modbus TCP server (port 502)
• Hardware Layer (modifiable GPIO interface via raspberrypi.cpp)
5. Sample programs (netPI_Test.st / .xml)
C. External Tools & Clients
– Portainer UI (manages container lifecycle)
– Web Browser (accesses OpenPLC GUI)
– SSH Client (remote shell)
– PLCOpen Editor (offline program authoring)
– Modbus Client Simulator (runtime testing)
Interactions & Data Flows
1. Operator uses Portainer → Docker Engine → starts container.
2. SSH Client ←→ SSH Daemon inside container.
3. Web Browser ←HTTP→ OpenPLC Webserver → OpenPLC Runtime.
4. PLCOpen Editor → uploads .st program via Web GUI.
5. Runtime ↔ Hardware Layer (raspberrypi.cpp) ↔ /dev/gpiomem → netPI GPIO.
6. Modbus Client Simulator ↔ Modbus TCP server in container.
Architectural Patterns & Principles
– Containerization: Isolation of services in one Docker image.
– Layered design: OS layer → init scripts → daemons → runtime core → hardware abstraction.
– Single‐process container (runs multiple daemons but you could split into microservices if desired).
– Hardware abstraction: custom GPIO layer isolates device-specific code.