9 breaking releases

0.10.0 Feb 3, 2022
0.8.0 Jan 11, 2022
0.7.0 Dec 10, 2021

#761 in Hardware support

MIT/Apache

145KB
1.5K SLoC

Yet Another Modbus Simulator

YAMS

A simulator for Modbus client/server that supports YAML based configuration and behavior definition, with pure Rust.

YAMS supports Modbus device configuration and behavior definition via YAML files. This means one can predefine how the simulator works before running the simulator, including:

  • the device type: Server/Client
  • the protocol type: Modbus TCP/RTU
  • communication configurations: IP address, baudrate, etc.
  • Modbus configurations: device ID etc.
  • Modbus server properties:
    • supported function codes
    • supported registers/coils and their values
    • overlapping of coil and register is supported
    • support user defined server behavior triggered by register/coil writes: With this feature enabled: YAMS will share the register/coil data with a user program via data (yaml) files. Each time a register/coil is updated, the user specified program will be invoked to update the register/coil data based on user-defined logic, as long as the external program writes the new data back to the files, YAMS will pick up the new data and continue running.
  • Modbus client behaviors:
    • requests to send to server(s)
    • support repeated request (single/multi request repeat)
    • support predefined delay before a request
  • Human friendly UI:
    • flexible YAML based configuration/request organization
    • supports verbose mode showing more details across the wire
    • supports print-out of request/response indexes
    • set and show measurements in its own type: 32-bit float for example

To support quick testing, Oneshot mode is provided so that one can run YAMS with only arguments from command line, though it is recommended to run with YAML configuration files to make the most out of YAMS.

Install

  • Make sure Cargo is installed. See the install page for details.
  • Install YAMS by cargo install yams.

Quick Demo:

DEMO

Configurable Items

See YAML based Configurations

Todo:

  • implement Modbus TCP support
  • implement YAML configuration/request support
  • implement Modbus RTU support
  • implement support for repeated request(s)
  • implement support for delay before request(s)
  • implement error handling
  • implement one-shot mode without config files
  • implement verbose mode to print out more detail/data
  • implement request/response counts printout
  • implement support for server behavior triggered by register/coil writes, defined by user
  • implement support for different endianness
  • implement all data support of all current functions, with tests
  • implement function code support below:
    • Read Coils
    • Read Discrete Inputs
    • Read Holding Registers
    • Read Input Registers
    • Write Single Coil
    • Write Single Register
    • Read Exception Status
    • Diagnostics
    • Get Comm Event Counter
    • Get Comm Event Log
    • Write Multiple Coils
    • Write Multiple Registers
    • Report Server ID
    • Read File Record
    • Write File Record
    • Mask Write Register
    • Read/Write Multiple registers
    • Read FIFO Queue
    • Encaptulated Interface Transport
    • CANopen General Reference Request and Response PDU
    • Read Device Identification

Dependencies

~9–21MB
~277K SLoC