No description
  • C 97.6%
  • Makefile 2%
  • Dockerfile 0.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-05-27 11:00:27 +02:00
docs docs generated by chatGPT 2026-04-27 09:22:37 +02:00
mongoose@5683677e68 basic api 2026-04-17 15:17:52 +02:00
.clangd thread, mb context, read/write 2026-04-16 14:48:13 +02:00
.gitignore yaml parser 2026-04-20 23:45:24 +02:00
.gitmodules basic api 2026-04-17 15:17:52 +02:00
args.c allow creating tcp simulators in runtime 2026-05-14 18:04:31 +02:00
args.h allow creating tcp simulators in runtime 2026-05-14 18:04:31 +02:00
array.h stop and start threads via api 2026-04-25 19:23:23 +02:00
config.c fix zero clients without config 2026-04-25 20:26:07 +02:00
config.h fix zero clients without config 2026-04-25 20:26:07 +02:00
cspell.json better query logging 2026-04-26 17:04:53 +02:00
Dockerfile change path 2026-05-27 11:00:27 +02:00
example.yaml stop and start threads via api 2026-04-25 19:23:23 +02:00
log.c dockerfile 2026-04-26 23:26:34 +02:00
log.h log modbus query 2026-04-26 09:30:33 +02:00
main.c allow creating tcp simulators in runtime 2026-05-14 18:04:31 +02:00
Makefile allow creating tcp simulators in runtime 2026-05-14 18:04:31 +02:00
mb_random_walk.c delete trace log 2026-04-25 11:02:18 +02:00
mb_sequence.c delete trace log 2026-04-25 11:02:18 +02:00
mb_utils.c allow read and write int16, int32, uint32, float in orders abcd, cdab 2026-04-26 20:24:49 +02:00
mb_utils.h allow read and write int16, int32, uint32, float in orders abcd, cdab 2026-04-26 20:24:49 +02:00
parse_yaml.c rename web_api to web; better cli argument parsing 2026-04-25 16:03:37 +02:00
parse_yaml.h better logs 2026-04-22 09:41:30 +02:00
README.md append dockerhub link 2026-04-27 09:34:49 +02:00
utils.c allow read and write int16, int32, uint32, float in orders abcd, cdab 2026-04-26 20:24:49 +02:00
utils.h allow read and write int16, int32, uint32, float in orders abcd, cdab 2026-04-26 20:24:49 +02:00
web.c get id from port 2026-05-14 19:15:59 +02:00
web.h use array instead of linked list for threads 2026-04-25 17:38:29 +02:00

Modbus Simulator

A lightweight Modbus TCP simulator designed for testing, development, and integration of Modbus-based systems.

The simulator provides:

  • Multiple Modbus TCP server instances
  • Configurable register generators
  • Optional HTTP API for runtime interaction
  • CLI and YAML-based configuration

Avaliable as docker image for amd64 and arm64: https://hub.docker.com/r/mrhlebusheck/modbus_simulator


Build

Dependencies

Debian (13+)

sudo apt update
sudo apt install -y \
  make \
  pkg-config \
  gcc \
  libmodbus-dev \
  libyaml-dev

Arch Linux

sudo pacman -S --needed \
  base-devel \
  pkgconf \
  libmodbus \
  libyaml

Compile

Debug build

make

Release build

make NDEBUG=1

Overview

The simulator can be started in two ways:

  • Using a YAML configuration file
  • Using command-line arguments (limited mode)

Configuration File

./build/modbus_simulator -c config.yaml

Provides full functionality, including:

  • Multiple simulators
  • Generators
  • Web API configuration

CLI Mode

./build/modbus_simulator --web 0.0.0.0:8080 --modbus tcp:0.0.0.0:502

Limitations:

  • No generator configuration
  • Only Modbus TCP supported

Features

  • Multiple independent Modbus TCP servers

  • Register types:

    • Coil
    • Discrete Input
    • Input Register
    • Holding Register
  • Data generators:

    • random_walk
    • sequence_walk
  • HTTP API:

    • Read/write registers
    • Control simulator lifecycle (start/stop)
  • Debug/verbose mode (global and per-component)


Documentation

  • usage.md — CLI usage and modes
  • config-yaml.md — YAML configuration reference
  • api.md — HTTP API specification

Notes

  • Register values are stored as 16-bit units internally.
  • 32-bit types and floats are mapped to two consecutive registers.
  • Designed primarily for development and testing.