Skip to content
Merged
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
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,21 @@ meter (2026-10-28). See [validation](docs/validation.rst) for the evidence scope
For a complete local simulator/MQTT demonstration, use the repository's
[Docker Compose example](examples/README.md).

### Read a catalog product and write a verification report
### Verify a Thing Model on a real device and write a report

`--device <manufacturer>/<model-number>[@<commit>]` reads the baseline Thing Model of a product in the
[Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog) instead of a file. A branch or tag
(default `main`) is resolved to its commit, and the download is checked against the Git object id GitHub
reports for it. `--full-read` reads every point once: read-only, without retries and with a timeout of at
most 10 seconds, so a lost request is a result and not something to repeat. `--report FILE` also writes the
verification report (`-` prints it):
`modpoll verify --config MODEL --tcp HOST` reads every point of a Thing Model once: read-only, without
retries and with a timeout of at most 10 seconds, so a lost request is a result and not something to repeat.
MODEL is a local TM/TD file, an http(s) URL or a `modiohub:<id>@<version>` Workspace reference. `--report
FILE` also writes the verification report (`-` prints it):

```sh
modpoll --device advantech/adam-5017uh --tcp 192.168.1.20 --unit-id 3 --report report.json
modpoll verify --config examples/modsim.tm.json --tcp 192.168.1.20 --unit-id 3 --product advantech/adam-5017uh --report report.json
```

The report records, per point, whether the read worked (`ok`, a Modbus `exception` with its code,
`no-response`, or `not-tested` when the answer could not be decoded) and your judgment of the value:
`--confirm POINT...` (or `all`) and `--reject POINT...` for values you compared with the device, otherwise
`unchecked`. `--chassis`, `--firmware` and `--configuration` add context. The report holds no address, Unit
`unchecked`. The report holds no address, Unit
ID, serial number or value; review it before sharing. It is checked with
[modpoll-wot](https://github.com/top-maker/modpoll-wot) (`modpoll-wot validate-report report.json --model
model.tm.json`), and `--export` still writes the snapshot of the same read. With `-f` for a local Thing
Expand All @@ -138,11 +136,12 @@ signing in with either tool signs in both. `MODIOHUB_TOKEN` in the environment r
revoke the session in your ModioHub settings to end it on the server.

Once signed in, `--config modiohub:<id>@<version>` (the version is a number or `latest`) reads one
of your custom Thing Models. A shared one needs no login. A full read of it writes a report that names the
Workspace model, and `--upload` shows the report and, after you confirm (or with `--yes`), uploads it:
of your custom Thing Models. A shared one needs no login. Verifying it names the Workspace model in the
report, and `modpoll verify --config ... --upload` shows the report and, after you confirm (or with `--yes`),
uploads it:

```sh
modpoll --config modiohub:k3x9f2m7q4a8n5bd@latest --tcp 192.168.1.20 --upload
modpoll verify --config modiohub:k3x9f2m7q4a8n5bd@latest --tcp 192.168.1.20 --upload
```

### MQTT data and write behavior
Expand Down
10 changes: 5 additions & 5 deletions docs/preview-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Modpoll 2.0.0a7 pins modpoll-wot 0.5.0a1 and connects to ModioHub:

- `--device <manufacturer>/<model>[@commit]` reads the baseline Thing Model of a catalog product.
- `--full-read` reads every point once, read-only and without retries; `--report FILE` writes the
verification report (schema 3), which holds no address, Unit ID, serial number or value.
- `modpoll verify --config MODEL --tcp HOST` reads every point of a Thing Model once, read-only and without
retries, and reports which points could be read; `--report FILE` writes the verification report (schema 3),
which holds no address, Unit ID, serial number or value.
- `modpoll login` signs in with your browser and `modpoll logout` forgets the login. The 7-day tool session
is kept in `~/.config/modiohub/credentials.json` and is shared with modsim 2.0.0a9.
- `--config modiohub:<id>@<version>` reads a custom Thing Model from your ModioHub Workspace, and `--upload` shows
the report of a full read and uploads it after you confirm.
- `--config modiohub:<id>@<version>` reads a custom Thing Model from your ModioHub Workspace, and
`modpoll verify --config ... --upload` shows the report and uploads it after you confirm.

## Modpoll 2.0.0a6 preview

Expand Down
17 changes: 17 additions & 0 deletions docs/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,20 @@ examples/modsim.csv`` and ``--config examples/modsim.tm.json`` exited 0 and
exported byte-identical snapshots of all 37 points; the CSV and TM poller
structures (four blocks, start addresses, quantities, endianness) match
exactly. ``--precision`` stays in the default ``auto`` rendering mode.


Verification command consolidation
----------------------------------

On 2026-11-12 the full-read flags became the ``modpoll verify`` subcommand and
the catalog fetch was removed (maintainer decision, after the 2.0.0a7
preview): ``modpoll verify --config MODEL --tcp HOST [--report FILE]
[--upload]`` replaces ``--full-read``/``--report``/``--upload`` at the top
level; ``--device`` is gone because ``--config`` already covers local files,
URLs and ``modiohub:`` Workspace references; ``--chassis``/``--firmware``/
``--configuration`` are gone because the report schema treats the environment
as optional. Verification options used without ``verify`` exit 2 with a
pointer to the command. After the change ``make check`` passed and the
offline suite passed 235 tests with 58 integration tests deselected,
including new refusal cases for the removed spellings and the verify
subcommand reaching the transport check.
55 changes: 16 additions & 39 deletions modpoll/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,70 +36,47 @@ def get_parser():
),
nargs="+",
)
parser.add_argument(
"--device",
metavar="MANUFACTURER/MODEL[@COMMIT]",
help=(
"Read the baseline Thing Model of a product in the Open Modbus Catalog, "
"for example advantech/adam-5017uh, at a commit, tag or branch "
"(default: main). Use instead of -f."
),
verification = parser.add_argument_group(
"verification",
"modpoll verify --config MODEL --tcp HOST reads every point of one Thing "
"Model once, read-only and without retries, and reports which points "
"could be read",
)
parser.add_argument(
"--full-read",
action="store_true",
help=(
"Read every point of the model once, read-only and without retries, "
"and report which points could be read. Implies --once."
),
)
parser.add_argument(
verification.add_argument(
"--report",
metavar="FILE",
help=(
"Write the verification report of a full read to FILE ('-' prints it). "
"Write the verification report to FILE ('-' prints it). "
"It lists each point's result and carries no address, Unit ID, serial "
"number or value; review it before sharing. Implies --full-read."
"number or value; review it before sharing."
),
)
parser.add_argument(
verification.add_argument(
"--upload",
action="store_true",
help=(
"After a full read, show the report and, once you confirm, upload it to "
"ModioHub (run modpoll login first). Implies --full-read."
"After the verification read, show the report and, once you confirm, "
"upload it to ModioHub (run modpoll login first)"
),
)
parser.add_argument(
verification.add_argument(
"--yes",
action="store_true",
help="Upload without asking for confirmation after the report is shown",
)
parser.add_argument(
verification.add_argument(
"--product",
metavar="MANUFACTURER/MODEL",
help="Catalog product ID the report is for; needed with -f, taken from --device otherwise",
)
parser.add_argument(
"--chassis",
metavar="MANUFACTURER/MODEL",
help="Chassis product ID, for the report",
)
parser.add_argument(
"--firmware", help="Firmware version of the device, for the report"
)
parser.add_argument(
"--configuration",
help="Short note on the device configuration, such as an input range, for the report",
help="Catalog product ID the report is for; needed when the model does not name one",
)
parser.add_argument(
verification.add_argument(
"--confirm",
nargs="+",
default=[],
metavar="POINT",
help="Points whose values you checked and found right ('all' for every point), for the report",
)
parser.add_argument(
verification.add_argument(
"--reject",
nargs="+",
default=[],
Expand Down
4 changes: 4 additions & 0 deletions modpoll/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ def setup_logging(level, format):
def app(name="modpoll"):
if sys.argv[1:2] in (["login"], ["logout"]):
sys.exit(login.command(sys.argv[1:]))
verify_mode = sys.argv[1:2] == ["verify"]
if verify_mode:
sys.argv = [sys.argv[0], *sys.argv[2:]]
mqtt_handler = None
modbus_handlers = []

Expand All @@ -201,6 +204,7 @@ def app(name="modpoll"):

# parse args
args = get_parser().parse_args()
args.verify = verify_mode

print(
f"\nModpoll v{__version__} - A New Command-line Tool for Modbus and MQTT\n",
Expand Down
Loading
Loading