Skip to content
forked from favalex/modbus-cli

Command line tool to access Modbus devices

License

Notifications You must be signed in to change notification settings

tggo/modbus-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

modbus

Access Modbus devices from the command line

Author: [email protected]
Date: 2017-06-04
Copyright: MPL 2.0
Version: 0.1
Manual section:1

SYNOPSIS

modbus [-h] [-r REGISTERS] [-s SLAVE_ID] [-b BAUD] [-p STOP_BITS] [-v] device access [access ...]

DESCRIPTION

modbus allows reading and writing registers of Modbus devices from the command line.

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

Register definitions (consisting of a register address and its type) can be provided directly on the command line or loaded from a file and referred by symbolic name, for convenience.

modbus is implemented in python on top of the protocol implementation provided by the umodbus python library.

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. --registers, -r=FILE Read registers definitions from FILE. --verbose, -v Print on screen the bytes as transfered on the wire. --baud, -b=BAUD Set the baud rate for serial connections. --stop-bits, -p=BITS Set the number of stop bits for serial connections. --help, -h Show this help message and exit.

ACCESS SYNTAX

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

MODBUS_TYPE = h|i|c|d

The modbus type, one of

code name size writable
h holding register 16 bits yes
i input register 16 bits no
c coil 1 bit yes
d discrete input 1 bit no
ADDRESS = <number>
0-based register address
BINARY_TYPE = <pack format>

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

The default byte order is big-endian, use a < prefix in the format to specify little-endian.

VALUE = <number>
The value to be written to the register. If not present, the register will be read instead.

REGISTERS FILE SYNTAX

A # starts a comment.

Each line contains a symbolic name followed by the register definition, separated by spaces.

EXAMPLES

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 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

SEE ALSO

About

Command line tool to access Modbus devices

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%