The jsmodbus CLI allows you to perform Modbus TCP read operations directly from the terminal. You can read Coils, Discrete Inputs, Holding Registers, or Input Registers by specifying the host, unit ID, and a range of addresses.
Command Syntax
jsmodbus <command> <host> <unitId> <range> [options]
Commands
fc01: Read Coilsfc02: Read Discrete Inputsfc03: Read Holding Registersfc04: Read Input Registers
Arguments
<host>: The IP address or hostname of the Modbus server.<unitId>: The Modbus Unit ID (integer).<range>: The address range to read, formatted as start:end (e.g., 0:10).
Options
-p, --port <port>: Modbus Port (defaults to 502).-r, --repeat <time>: Repeat the request at the specified interval in milliseconds.-b, --buffer: Print the output as a Buffer instead of an array.-t, --timeout <timeout>: Connection timeout in milliseconds (defaults to 2000).-bm, --benchmark: Show timestamp benchmark information (transfer and wait times).
# Example: Read holding registers from 0 to 10 on host 127.0.0.1, port 502, repeating every 1000ms
jsmodbus fc03 127.0.0.1 1 0:10 --port 502 --repeat 1000