xref: /openbmc/phosphor-modbus/mocked_test_device/Readme.md (revision 2168bbd050af3c68d820f96054a939dda02688c6)
1*2168bbd0SJagpal Singh Gill# Mock Modbus Test Device
2*2168bbd0SJagpal Singh Gill
3*2168bbd0SJagpal Singh Gill## mock-modbus-device
4*2168bbd0SJagpal Singh Gill
5*2168bbd0SJagpal Singh GillThe `mock-modbus-device` daemon launches a simulated Modbus server on a
6*2168bbd0SJagpal Singh Gillspecified PTY port ID. This server listens for Modbus requests and returns
7*2168bbd0SJagpal Singh Gillstatic data. At present, it only supports the ReadHoldingRegisters command, with
8*2168bbd0SJagpal Singh Gillplans to add more command support in the future.
9*2168bbd0SJagpal Singh Gill
10*2168bbd0SJagpal Singh Gill## start_mock_server.sh
11*2168bbd0SJagpal Singh Gill
12*2168bbd0SJagpal Singh GillThe `start_mock_server.sh` script acts as a wrapper for `mock-modbus-device`. It
13*2168bbd0SJagpal Singh Gillaccepts a count parameter and starts a separate mocked Modbus server for each
14*2168bbd0SJagpal Singh GillPTY port. The script also configures the necessary environment variables to
15*2168bbd0SJagpal Singh Gillenable client communication with the mocked servers. It utilizes socat to create
16*2168bbd0SJagpal Singh Gillpseudo-terminals (PTYs) and initiates a `mock-modbus-device` instance for each
17*2168bbd0SJagpal Singh GillPTY.
18*2168bbd0SJagpal Singh Gill
19*2168bbd0SJagpal Singh GillThis approach enables clients to interact with simulated Modbus devices,
20*2168bbd0SJagpal Singh Gillfacilitating testing across different scenarios without requiring physical
21*2168bbd0SJagpal Singh Gillhardware. It is particularly suited for Qemu-based testing. To use this setup,
22*2168bbd0SJagpal Singh Gillusers must manually copy the required artifacts to the Qemu VM and execute the
23*2168bbd0SJagpal Singh Gillscript to start the mocked Modbus servers.
24