
ssweber (Customer) asked a question.
Hey! After my work on ClickNick, I've been building some some additional Python tools for working with CLICK PLCs. One library is called pyclickplc. It handles Modbus TCP, address parsing, nickname.csv, DataView file generation, etc.
One thing I thought might be useful for you: it can spin up a simulated CLICK PLC as a Modbus TCP server in a few lines of Python. Like when you need a Modbus port to test a Send/Receive instruction against:
- import asyncio
- from pyclickplc import ClickServer, MemoryDataProvider
-
- async def main():
- provider = MemoryDataProvider()
- provider.bulk_set({"DS1": 100, "DS2": 200, "C1": True})
-
- async with ClickServer(provider, host="0.0.0.0", port=502):
- print("Modbus server running on port 502 — Ctrl+C to stop")
- await asyncio.Event().wait()
-
- asyncio.run(main())
Point your click's Send/Receive instruction at the machine running this and it'll respond like a CLICK PLC. You can pre-load registers with bulk_set to have test data.
Note: 0.0.0.0 makes it available on your local network so the PLC can reach it. You may need to allow the port through Windows Firewall (it usually prompts you on first run).
Install with uv add pyclickplc or pip install pyclickplc (Python 3.11+). More details at the repo:
To give credit: https://pypi.org/project/clickplc/ had already existed. I wanted to clean up the api and provide a matching server implementation for easy testing, as well as file operations.