Skip to the content.

SHM Modbus - Shared Memory Randomize

SHM Modbus > Modbus Tools > random

The shared-mem-random application writes random values to a shared memory. It can use an existing shared memory or create a new one.

Usage

Shared Memory Options

Other Options

Examples

Example 1

shared-mem-random -n my_shm -c 1024 -a 2 -i 500

This command creates a shared memory named my_shm with a size of 1024 bytes, generating random values aligned on a 2-byte boundary at intervals of 500 milliseconds.

Example 2

shared-mem-random -n my_shm -s my_sem -l 1

This command generates random values and writes them once to a shared memory named my_shm, while using an existing semaphore named my_sem for protection against simultaneous access.

Example 3

shared-mem-random -n modbus_DO -s modbus -a 1 -b 1 --pid $(pidof shared-mem-random)

This command generates random values and writes them to a shared memory named modbus_DO, utilizing a semaphore named modbus for protection against simultaneous access. Random values are generated with a byte alignment of 1 at intervals of 500 milliseconds, and a bit mask of 1 is applied to the generated random values. Thus, only the lowest bit of each byte is randomized. Additionally, it sets up termination of the shared-mem-random application if the process with the PID of the shared-mem-random application terminates.

Example 4

shared-mem-random -n my_shm -a 8 -o 64 -e 8 -l 1

This command configures the shared-mem-random application to write random values to a shared memory named my_shm. The random values are generated with an 8-byte alignment and are written starting from an offset of 64 bytes within the shared memory. The application processes a maximum of 8 elements and runs for a single iteration, generating random values only once before exiting.

Install

The application is available as shared-mem-random in the Arch User Repository. See the Arch Wiki for information about how to install AUR packages.

Using the Modbus Collection Package: SHM Modbus

SHM Modbus is a collection of multiple tools to simulate a Modbus client.

Flatpak

The Flatpak package is available via Flathub as io.github.shmmodbus.shm-modbus.

shared-mem-random is invoked by executing the following command:

flatpak run io.github.shmmodbus.shm-modbus shared-mem-random

Snap

The snap package can be downloaded via the github release page.

shared-mem-random is invoked by executing the following command:

shm-modbus.shared-mem-random