-
-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Summary
Add a built-in HTTP/REST API to the Modbus mock server that allows reading and writing register values at runtime — without requiring a Modbus client.
Motivation
A REST interface is arguably the most requested feature for Modbus mock servers. Many teams rely on CI/CD pipelines and integration test frameworks that have no native Modbus client available. Forcing these workflows to spin up a dedicated Modbus client just to seed or verify register values adds unnecessary complexity and friction.
Proposed API
A minimal, intuitive interface could look like this:
# Read a holding register
GET /registers/holding/42
# Write a holding register
POST /registers/holding/42
Content-Type: application/json
{ "value": 1337 }
The same pattern should apply to all register types (coil, discrete, input, holding).
Use Cases
- Prepopulating register values before a test run
- Asserting register state after a device interaction in automated tests
- Integrating with test orchestration tools (e.g. pytest, Postman, GitHub Actions) without a Modbus dependency
- Resetting or inspecting mock state via simple curl commands during development
Expected Behavior
- The HTTP server runs alongside the Modbus server on a configurable port
- Responses are JSON-formatted
- Errors (e.g. invalid register address) return appropriate HTTP status codes (400, 404, etc.)
Why This Matters
This feature would significantly lower the barrier to using the mock server in modern DevOps and testing workflows, where HTTP is the lingua franca for tooling integration.