Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/modbus/actions/proc_modbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ def _read_batch(read_func, start_address, highest_addr, device_id):


@ModbusClient.action
def scan_modbus(self, device_id=1):
def scan_modbus(self, start_address=0, device_id=1):
"""
Protocol Function
Modbus Scan Registers
"""
address = 0
address = start_address
self.log.info(
f"Scanning Modbus device -- [Start Address: {address}, Device ID: {device_id}]"
)
Expand Down
10 changes: 9 additions & 1 deletion src/modbus_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ def add_scan_subparser(subparsers):
"scan",
help="Scan Modbus Device: Automatically discover and read all available registers",
)
parser.add_argument(
"--start",
dest="start",
type=to_16bit_uint,
required=False,
default=0,
help="Starting address for the scan [0-65535] (default: 0)",
)
add_device_id_arg(parser)


Expand Down Expand Up @@ -466,7 +474,7 @@ def do_action(client, args):
elif args.action.lower() == "scan":
print("[*] Scanning Modbus device")
try:
result = client.scan_modbus(args.device_id)
result = client.scan_modbus(args.start, args.device_id)
except Exception as err:
print(f"Scan failed: {err}")
log.error(err)
Expand Down