Skip to main content
Loading...
Free Command Line Windows / Linux

diagslave - Modbus Slave Simulator

Free lightweight command-line Modbus slave simulator for testing master devices. Supports RTU and TCP protocols with configurable register data. No hardware needed - test your PLCs, gateways and SCADA systems virtually.

File Size

195 KB (ZIP)

Platform

Windows / Linux

Protocols

Modbus RTU + TCP

Type

CLI (Command Line)

Overview

diagslave is a command-line Modbus slave simulator that responds to Modbus master requests without requiring any physical hardware. It is the companion tool to modpoll - while modpoll acts as a master, diagslave acts as a slave, enabling you to create complete test loops on a single computer.

This tool is invaluable during PLC programming, gateway commissioning, and SCADA system development. Instead of connecting to real field devices (which may not be available during development), diagslave provides a virtual Modbus slave that responds to all standard function codes.

Key Features

🌐 TCP Slave Mode

Simulate a Modbus TCP slave device on any port. Multiple instances can run on different ports simultaneously.

⚙ RTU Slave Mode

Simulate a Modbus RTU serial slave device. Supports virtual COM port pairs for local testing.

📦 Ultra Lightweight

Under 200KB. No installation or dependencies. Instant startup - ideal for rapid testing cycles.

💻 Configurable Data

Set register values via command-line arguments. Slave responds with the configured data to any master request.

Quick Start

Start a Modbus TCP Slave

# Start TCP slave on port 502, slave address 1 diagslave -m tcp -p 502 # Start TCP slave on custom port 1502 diagslave -m tcp -p 1502

Start a Modbus RTU Slave

# Start RTU slave on COM1, 9600 baud, no parity diagslave -m rtu -b 9600 -p none COM1 # Start RTU slave on Linux serial port diagslave -m rtu -b 19200 -p even /dev/ttyUSB0

Creating a Test Loop

The most powerful use case is running diagslave + modpoll together on the same machine to create a complete Modbus test loop:

# Terminal 1: Start the slave simulator diagslave -m tcp -p 5020 # Terminal 2: Send master requests to the slave modpoll -m tcp -a 1 -r 0 -c 10 -1 127.0.0.1:5020

Common Command-Line Options

FlagDescriptionExample
-mProtocol: tcp or rtu-m tcp
-pTCP port (TCP) or parity (RTU)-p 502
-bBaud rate (RTU only)-b 9600
-aSlave address (1-247)-a 1

Compatible with ModulesLink Products

Use diagslave to simulate field devices when testing ModulesLink Modbus gateways during development. Configure the slave with the same register map as your target sensors and meters to validate gateway configuration before connecting to real hardware.

Frequently Asked Questions

What is diagslave used for?
diagslave is a Modbus slave simulator used to test Modbus master devices (PLCs, gateways, SCADA systems) without needing physical slave hardware. It responds to Modbus requests with configurable register data, enabling complete virtual testing environments.
How to simulate a Modbus slave with diagslave?
Run diagslave with the desired protocol mode. For TCP: diagslave -m tcp -p 502. For RTU: diagslave -m rtu -b 9600 -p none COM1. The slave will respond to all incoming Modbus master requests with default register values.