SCADA / modbus / misc /
root authored on 8 May 2022
..
ModbusPal.jar playing with modbus day #1 2 years ago
README.md playing with modbus day #1 2 years ago
dump_odd.py playing with modbus day #1 2 years ago
live_monitor.rb playing with modbus day #1 2 years ago
mocli.py playing with modbus day #1 2 years ago
pymodmon.py playing with modbus day #1 2 years ago
pymodmon_3.py playing with modbus day #1 2 years ago
read_all_holding_registers.py playing with modbus day #1 2 years ago
read_register.py playing with modbus day #1 2 years ago
register_scanner.py playing with modbus day #1 2 years ago
register_scanner.py.1 playing with modbus day #1 2 years ago
write_all_holding_registers.py playing with modbus day #1 2 years ago
README.md
  • dump_odd.py, dump all data that doesn't have the default value
  • live_monitor.rb, Allows you to scan, at a regular time, all Modbus registries of a device.
  • mocli.py, A Command Line Interface for pymodbus
  • read_all_holding_registers.py, used to scan and get values from holding registers on a TCP Modbus Slave;
  • write_all_holding_registers.py, used to write a specific value to one or multiple holding registers of a TCP Modbus Slave;
  • read_register.py, used to get values from various types of addresses on a TCP Modbus Slave (Holding Register, Discrete Input, Input Register)
  • pymodmon.py, monitor several modbus addresses with a configurable interval and can also write the received data to a csv file.
  • pymodmon_3.py, updated version of above script for python 3
  • register_scanner.py, Script take IP as input and brute force against all the registers. Identified valid registered will be exported to excel file
  • modbuspal.jar, PC-based Modbus simulator. Its goal is to reproduce a realistic environment, with many slaves and animated register values.

live_monitor.rb

Usage : ruby live_monitor.rb IP_ADDRESS TIME_IN_SECONDS

live_monitor.rb

Usage : python register_scanner.py -i ip_addr

read_all_holding_registers.py

usage: read_all_holding_registers.py [-h] [-p PORT] [-u UID] [-sa START]
                                      [-ea END]
                                      ip

Read all holding registries from a TCP MODBUS Slave

positional arguments:
  ip                    IP address of the slave

optional arguments:
  -h, --help            show this help message and exit
  -p PORT, --port PORT  Modbus Port. Defaults to 502
  -u UID, --uid UID     Modbus Unit ID. Defaults to 1
  -sa START, --start-address START
                        Starting Address for the scanner. Defaults to 1
  -ea END, --end-address END
                        Ending Address for the scanner. Defaults to 65535

write_all_holding_registers.py

usage: write_all_holding_registers.py [-h] [-p PORT] [-u UID] [-sa START]
                                      [-ea END] [-v VALUE]
                                      ip

Write all holding registries on a TCP MODBUS Slave

positional arguments:
  ip                    IP address of the slave

optional arguments:
  -h, --help            show this help message and exit
  -p PORT, --port PORT  Modbus Port. Defaults to 502
  -u UID, --uid UID     Modbus Unit ID. Defaults to 1
  -sa START, --start-address START
                        Starting Address for the writer. Defaults to 1
  -ea END, --end-address END
                        Ending Address for the writer. Defaults to 65535
  -v VALUE, --value VALUE
                        Value that will be written. Defaults to 7777

read_register.py

usage: read_register.py [-h] [-p PORT] [-u UID] [-sa START] [-ea END]
                        [-t TYPE]
                        ip

Read specific addresses on a TCP MODBUS Slave

positional arguments:
  ip                    IP address of the slave

optional arguments:
  -h, --help            show this help message and exit
  -p PORT, --port PORT  Modbus Port. Defaults to 502
  -u UID, --uid UID     Modbus Unit ID. Defaults to 1
  -sa START, --start-address START
                        Starting Address for the scanner. Defaults to 1
  -ea END, --end-address END
                        Ending Address for the scanner. Defaults to 65535
  -t TYPE, --type TYPE  Type of Modbus address to read. Values can be 'h' for
                        Holding, 'd' for Discrete Inputs or 'i' for Input
                        Registers. Defaults to 'h'

PyModMon

Python Modbus Monitor

This is a Python skript that acts as a Modbus slave. It can be used e.g. for reading data from newer solar inverters made by SMA.

It has the ability to monitor several modbus addresses with a configurable interval and can also write the received data to a csv file.

The logged data can then be used with other programs for analysing or plotting.

Dependencies:

  • Python 2.7
  • Python package docopt
  • Python package pymodbus (and dependencies)

pymodmon_3.py is the updated version for Python 3 (tested with Python 3.7). No additional functionality was added.