All Projects → favalex → modbus-cli

favalex / modbus-cli

Licence: MPL-2.0 license
Command line tool to access Modbus devices

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to modbus-cli

Umodbus
Python implementation of the Modbus protocol.
Stars: ✭ 129 (+59.26%)
Mutual labels:  modbus
Oshmi
SCADA HMI for substations and automation applications.
Stars: ✭ 180 (+122.22%)
Mutual labels:  modbus
Modbus.net
A high extensible hardware communication platform using C#
Stars: ✭ 244 (+201.23%)
Mutual labels:  modbus
Libmodbus
A Modbus library for Linux, Mac OS X, FreeBSD, QNX and Windows
Stars: ✭ 2,019 (+2392.59%)
Mutual labels:  modbus
J2mod
Enhanced Modbus library implemented in the Java programming language
Stars: ✭ 155 (+91.36%)
Mutual labels:  modbus
Qtswissarmyknife
QSAK (Qt Swiss Army Knife) is a multi-functional, cross-platform debugging tool based on Qt.
Stars: ✭ 196 (+141.98%)
Mutual labels:  modbus
Liblightmodbus
A cross-platform, lightweight Modbus RTU library
Stars: ✭ 121 (+49.38%)
Mutual labels:  modbus
EasyModbusTCP.Java
EasyModbusTCP library for Java implementation
Stars: ✭ 76 (-6.17%)
Mutual labels:  modbus
Minimalmodbus
Easy-to-use Modbus RTU and Modbus ASCII implementation for Python.
Stars: ✭ 166 (+104.94%)
Mutual labels:  modbus
Mbusd
Open-source Modbus TCP to Modbus RTU (RS-232/485) gateway.
Stars: ✭ 233 (+187.65%)
Mutual labels:  modbus
Genmon
Generac Generator Monitoring using a Raspberry Pi and WiFi
Stars: ✭ 143 (+76.54%)
Mutual labels:  modbus
Sharpscada
C# SCADA
Stars: ✭ 2,043 (+2422.22%)
Mutual labels:  modbus
Ohsce
PHP HI-REL SOCKET TCP/UDP/ICMP/Serial .高可靠性PHP通信&控制框架SOCKET-TCP/UDP/ICMP/硬件Serial-RS232/RS422/RS485 AND MORE!
Stars: ✭ 206 (+154.32%)
Mutual labels:  modbus
Actorcloud
Open-source IoT Platform
Stars: ✭ 138 (+70.37%)
Mutual labels:  modbus
QUaModbusClient
Modbus to OPC UA Gateway
Stars: ✭ 38 (-53.09%)
Mutual labels:  modbus
Mbserver
Golang Modbus Server (Slave)
Stars: ✭ 124 (+53.09%)
Mutual labels:  modbus
Modbustool
A modbus master and slave test tool with import and export functionality, supports TCP, UDP and RTU.
Stars: ✭ 187 (+130.86%)
Mutual labels:  modbus
ModbusScope
ModbusScope logs data for analysis using the Modbus protocol.
Stars: ✭ 29 (-64.2%)
Mutual labels:  modbus
tinnymodbus
RS485 ModBus tiny multi-sensor module
Stars: ✭ 75 (-7.41%)
Mutual labels:  modbus
Pyscada
PyScada is a open source scada system that uses the Django framework as backend
Stars: ✭ 233 (+187.65%)
Mutual labels:  modbus

modbus

Access Modbus devices from the command line

Author: [email protected]
Date: 2022-10-16
Copyright: MPL 2.0
Version: 0.1.8
Manual section:1

SYNOPSIS

modbus [-h] [-r REGISTERS] [-s SLAVE_ID] [-b BAUD] [-p STOP_BITS] [-P {e,o,n}] [-v] device access [access ...]

DESCRIPTION

Read and write registers of Modbus devices.

Access both TCP and RTU (i.e. serial) devices and encode and decode types larger than 16 bits (e.g. floats) into Modbus 16 bits registers.

Optionally access registers by symbolic names, as defined in a registers file. Symbolic names for enumerations and bitfields are supported too.

Designed to work nicely with other standard UNIX tools (watch, socat, etc.), see the examples.

Implemented in python on top of the protocol implementation provided by the umodbus python library.

INSTALL

Regular python install, either pip install modbus_cli to install from pypi or python setup.py install to install from source.

OPTIONS

device
/dev/ttyXXX for serial devices, or hostname[:port] for TCP devices
access
One or more read or write operations. See ACCESS SYNTAX below.
-r FILE, --registers=FILE
 Read registers definitions from FILE. Can be specified multiple times.
-v, --verbose Print on screen the bytes transferred on the wire.
-b BAUD, --baud=BAUD
 Set the baud rate for serial connections.
-p BITS, --stop-bits=BITS
 Set the number of stop bits for serial connections.
-P PARITY, --parity=PARITY
 Set the parity for serial connections: (e)ven, (o)dd or (n)one
-B ORDER, --byte-order=ORDER
 Set the byte order to one of 'le' (little endian), 'be' (big endian) or 'mixed'
-h, --help Show this help message and exit.

ACCESS SYNTAX

[MODBUS_TYPE@]ADDRESS[/BINARY_TYPE][:ENUMERATION_NAME][=VALUE]

Mnemonic: access the register(s) of MODBUS_TYPE starting at ADDRESS, interpreting them as BINARY_TYPE. The / syntax is inspired by gdb (but the available types are different.)

MODBUS_TYPE = h|H|i|c|C|d

The modbus type, one of

code name size writable
h or H holding register 16 bits yes
i input register 16 bits no
c or C coil 1 bit yes
d discrete input 1 bit no

Types C and H force the use of "write multiple registers" even when accessing a single register. This is useful for some devices that don't support singular write functions.

The default modbus type is holding register.

ADDRESS = <number>
0-based register address
BINARY_TYPE = <pack format>

Any format description accepted by the python standard pack module. Some common formats are:

code type
h 16 bits signed integer
H 16 bits unsigned integer
i 32 bits signed integer
I 32 bits unsigned integer
f 32 bits IEEE 754 float

The default byte order is big-endian. To use little endian, use a < prefix, or --byte-order=le. To use mixed endian (little endian, but individual 16 bit registers are big endian), use --byte-order=mixed.

VALUE = <number>

The value to be written to the register. If not present, the register will be read instead.

If only one register is written to, the modbus function 6 (0x6), "write single register" is used. If multiple registers are written to, the modbus function 16 (0x10), "write multiple registers" is used.

EXAMPLES

Read a holding register

$ modbus $IP_OF_MODBUS_DEVICE 100

Write a holding register

$ modbus $IP_OF_MODBUS_DEVICE 100=42

Read multiple registers

To read (or write) multiple registers simply list them on the command line:

$ modbus $IP_OF_MODBUS_DEVICE 100 c@2000

When performing access to multiple contiguous registers, one single modbus operation is performed.

When multiple modbus operations are needed, they are all initiated at once, and the results are collected as they arrive.

More examples of the access syntax

h@39/I read the 32-bits unsigned integer stored in holding registers at addresses 39 and 40
39/I same as above (h is the default modbus type)
39/I=42 write the integer 42 to that register
SOME_REGISTER=42 same as above, provided the registers file contains the definition SOME_REGISTER h@39/I
39/I=0xcafe the value can be specified in hexadecimal
c@5 read coil at address 5
h@24/f=6.78 write a floating point value to holding registers at addresses 24 and 25
i@1/6B read six unsigned bytes stored in input registers at addresses 1, 2 and 3

Monitor a register

The UNIX command watch can be used to read a register at regular intervals:

$ watch modbus $IP_OF_MODBUS_DEVICE 100

Read a serial device attached to a remote computer

The UNIX command socat can be used to access a remote device through a TCP tunnel:

remote$ socat -d -d tcp-l:54321,reuseaddr file:/dev/ttyUSB0,raw,b19200
local$ socat -d -d tcp:sc:54321 pty,waitslave,link=/tmp/local_device,unlink-close=0
local$ modbus /tmp/local_device 100

Read multiple registers based on their names

Given the following registers definitions:

$ cat registers.modbus
di0 d@0
di1 d@1
ai0 i@512
ai1 i@513

glob matching (*, ?, etc.) can be used to read all the ai registers at once:

$ modbus -r registers.modbus $IP_OF_MODBUS_DEVICE ai\*

REGISTERS FILES

The purpose of the registers files is to be able to refer to registers by name.

There can be multiple definition files, specified using either the -r command line switch or the MODBUS_DEFINITIONS environment variable.

A # in a definition file starts a comment.

Each line contains a symbolic name followed by a register definition. The name and the definitions are separated by spaces, for example:

status i@512:STATUS
leds 513:LEDS

The file can also contain the possible values for an enumeration or a bitmask, for example:

# This is an enumeration named STATUS
:STATUS
  0=OFF
  1=ON
  2=ERROR

# This is a bitmask named LEDS
|LEDS
  0=LED0
  1=LED1
  3=LED3
  4=LED4

ENVIRONMENT

MODBUS_DEFINITIONS
A colon separated list of register definitions files.

SEE ALSO

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].