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
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
> **2.x development branch.** This checkout accepts WoT TM/TD JSON using profile 0.2. CSV remains supported on the 1.x `main` branch. Install the current preview with `uv tool install --prerelease allow 'modpoll[serial]==2.0.0a7'`; stable 1.x remains available with `uv tool install 'modpoll<2'`. For development, run `make install`, then prefix project commands with `uv run`.
> **2.x development branch.** This checkout accepts v1 CSV and WoT TM/TD JSON using profile 0.2; `--config` detects the format from the content. Install the current preview with `uv tool install --prerelease allow 'modpoll[serial]==2.0.0a7'`; stable 1.x remains available with `uv tool install 'modpoll<2'`. For development, run `make install`, then prefix project commands with `uv run`.

# Modpoll - A New Command-line Tool for Modbus and MQTT

Expand Down Expand Up @@ -92,9 +92,12 @@ The existing transport, polling, output and MQTT arguments remain available.
See the [current profile](https://github.com/top-maker/modpoll-wot/blob/main/profile.md) for field mapping,
access flags, byte order, multiplier semantics and supported limits; the
[execution contract](https://github.com/top-maker/modpoll-wot/blob/main/CONTRACT.md) defines the profile 0.2-only input policy.
The configuration loader rejects CSV and reports invalid model fields before
polling. Each model describes one device; use multiple `--config` paths for
multiple devices. Give each model a unique `title`, which is the output device name.
The configuration loader detects the format from the content and reports invalid
model fields before polling. Each model describes one device; use multiple
`--config` paths for multiple devices. Give each model a unique `title`, which is
the output device name. Existing v1 CSV configurations load through the same
`--config` argument; use `--thing-model` or
`--thing-description`/`--td` to assert the JSON document kind explicitly.

Physical RS485 polling has also been verified by the maintainer with an Eastron
meter (2026-10-28). See [validation](docs/validation.rst) for the evidence scope and
Expand Down
7 changes: 4 additions & 3 deletions contrib/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Contributed device references

This directory retains vendor register documentation and contributed mappings.
CSV files are v1 migration sources; modpoll 2.x accepts TM/TD JSON only. Use the
CSV files are v1 migration sources; modpoll 2.x loads them again through the
same `--config` content detection, and new configurations should still be
written as profile 0.2 Thing Models. Use the
[migration guide and AI prompt](../docs/site/csv-migration.rst), then validate the new
file with `modpoll-wot validate MODEL --profile` and compare known device
readings. This command requires the next shared package release or the candidate
source; the published `modpoll-wot==0.2.0a1` does not include it.
readings.

The maintainer confirmed successful polling of an Eastron meter over physical
RS485 on 2026-10-28. This is manual hardware evidence in addition to automated
Expand Down
59 changes: 39 additions & 20 deletions docs/site/configure.rst
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
WoT TM/TD configuration
=======================
CSV and WoT TM/TD configuration
===============================

The 2.x development branch accepts JSON configurations using WoT TM/TD 1.1.
Use the same ``--config`` argument for either format. A top-level ``@type``
containing ``tm:ThingModel`` (a string or an array entry) selects TM validation;
otherwise the document is validated as TD. File extensions and URL suffixes do
not select the format. An invalid document fails its selected validation; the
loader does not retry it as the other format. This preview supports the fixed
``tm:ThingModel`` spelling, without resolving alternate JSON-LD aliases.
The 2.x development branch accepts both the v1 CSV configuration format and
JSON configurations using WoT TM/TD 1.1. ``-f``/``--config`` (alias ``--tm``)
takes either format and detects it from the content, not the file name or URL
suffix: a first
non-whitespace byte of ``{`` or ``[`` selects JSON; anything else is parsed as
v1 CSV. The same argument also accepts a ``modiohub:<id>@<version>`` reference
to a custom Thing Model in your ModioHub Workspace (run ``modpoll login``
first unless the version is shared); a reference is always a Thing Model.
``--thing-model`` and ``--thing-description``/``--td`` assert
the JSON document kind explicitly and reject content of the other kind (or a
CSV file) with a configuration error; they take local paths or URLs only.

It rejects CSV input. The canonical ``examples/modsim.tm.json`` uses profile
0.2 standard property Forms and explicit acquisition blocks. The generated
``examples/modsim.generated.td.json`` binds that same 37-property model to local
TCP at port 5020. Current development source accepts only profile 0.2; older
profiles must be migrated. Details are in ``packages/modpoll-wot/profile.md``.
For JSON input, a top-level ``@type`` containing ``tm:ThingModel`` (a string or
an array entry) selects TM validation; otherwise the document is validated as
TD. An invalid document fails its selected validation; the loader does not
retry it as the other format. This preview supports the fixed ``tm:ThingModel``
spelling, without resolving alternate JSON-LD aliases.

The v1 CSV row format (``device``, ``poll`` and ``ref`` rows) keeps its original
semantics: point names replace ASCII spaces with underscores, a blank access
column defaults to ``r``, the scale column multiplies the decoded value, and
bit-table point addresses identify eight-bit groups. ``--unit-id`` overrides
the per-device ID column; ``--param`` placeholder bindings require a Thing
Model and are rejected for CSV. The canonical ``examples/modsim.csv`` produces
the same four blocks and 37 points as ``examples/modsim.tm.json``. Current
development source accepts only profile 0.2; older profiles must be migrated.
Details are in the `modpoll-wot profile documentation
<https://github.com/top-maker/modpoll-wot/blob/main/profile.md>`_.

Each file describes one device. Its ``title`` is the output device name;
``--unit-id`` overrides the instance Unit ID (range 1–254). Without it, each file
uses the Unit ID declared consistently in its Forms, falling back to 1. Different files
can therefore address different Unit IDs in one process.
Multiple files may be supplied to ``--config``; titles must be unique.
Multiple files may be supplied per flag, and the three flags may be combined;
files load in ``--config``, ``--thing-model``, ``--thing-description`` order.
Device names must be unique across all files.
The existing transport CLI arguments explicitly select the connection endpoint.
A concrete TD's form Unit IDs, addresses and quantities must agree with the model.

Expand Down Expand Up @@ -53,8 +70,9 @@ Migration from CSV
* Preserve effective point names from legacy ``ref`` rows: the old loader replaced spaces with
underscores. Unknown types or ambiguous fields require review.

The executable contract and test vectors live under
``packages/modpoll-wot``. Strings, bit selectors, four tables and all four
The executable contract and test vectors live in the
`modpoll-wot repository <https://github.com/top-maker/modpoll-wot>`_. Strings,
bit selectors, four tables and all four
byte/word orders are represented by the contract. Model inheritance, optional members, URI templates, non-Modbus forms,
and security schemes other than ``nosec`` are rejected in this preview subset.
The interpreter records access flags; raw MQTT write commands retain the existing
Expand All @@ -68,9 +86,10 @@ fixes and :doc:`csv-migration` for the reusable AI conversion prompt.
Standard Form profile 0.2
-------------------------

The shared package ``0.2.0a1`` introduces profile ``0.2`` with standard Form
The shared ``modpoll-wot`` package provides profile ``0.2`` with standard Form
mappings and explicit blocks. The application uses the exact published package
version. See
``packages/modpoll-wot/profile.md`` for API details, parameter precedence,
version. See the
`profile documentation <https://github.com/top-maker/modpoll-wot/blob/main/profile.md>`_
for API details, parameter precedence,
necessary extensions and external Consumer limits. The source example is
``examples/modsim.tm.json``. Generated TDs are instance artifacts.
22 changes: 14 additions & 8 deletions docs/site/csv-migration.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
Migrating CSV configurations
============================

v1 remains available for existing CSV users. v2 accepts TM/TD JSON and provides
an offline validator; it does not load CSV or invoke an AI service at runtime.
Convert new configurations to profile 0.2 as described in
``packages/modpoll-wot/profile.md``. Current development source rejects profile
v2 loads v1 CSV configurations again: pass them to ``--config`` as before, and
the format is detected from the content. Existing v1 commands keep working
unchanged. Migrating to profile 0.2 remains the recommended path for new or
heavily edited configurations, because a Thing Model is validated offline,
carries access and unit metadata explicitly, and is what the ModioHub catalog
publishes. v2 does not invoke an AI service at runtime.
Convert configurations to profile 0.2 as described in the
`modpoll-wot profile documentation
<https://github.com/top-maker/modpoll-wot/blob/main/profile.md>`_. Current
development source rejects profile
0.1; migrate its member mapping into Forms and use physical bit addresses.
Check the executable profile and bundled schemas before using a conversion.

Expand Down Expand Up @@ -32,10 +38,10 @@ Migration procedure
Review the report before using the file on a device. A successful schema check
alone cannot certify a vendor register map.

Commands from the development checkout (the validation command uses the
candidate shared package; version 0.2.0a1 does not provide this subcommand)::
Commands from the development checkout (the pinned ``modpoll-wot`` dependency
provides the validation subcommand)::

PYTHONPATH=packages/modpoll-wot uv run python -m modpoll_wot validate meter.tm.json --profile
uv run python -m modpoll_wot validate meter.tm.json --profile
uv run modpoll --once --config meter.tm.json --tcp HOST --tcp-port PORT --export data.json
uv run modpoll --config first.tm.json second.tm.json --tcp HOST

Expand Down Expand Up @@ -112,7 +118,7 @@ Review checklist
* Access corrections and rejected source mistakes are explicit in the report.
* All JSON files pass the offline profile validator; independent vectors and
output comparisons pass. Unknown vendor facts remain unresolved, not guessed.
* No runtime CSV fallback, AI calls or device-library dependency is introduced.
* No AI calls or device-library dependency are introduced at conversion time.

The authored ``examples/modsim.tm.json`` / ``modsim.generated.td.json`` pair and the
independent vectors in the tests demonstrate the process. Migrating the entire
Expand Down
5 changes: 3 additions & 2 deletions docs/site/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
Welcome to Modpoll's documentation!
===================================

This is the 2.x preview documentation. Choose `1.x / CSV <https://top-maker.github.io/modpoll/1.x/>`_
or `2.x / TM/TD <https://top-maker.github.io/modpoll/v2/>`_.
This is the 2.x preview documentation (CSV and TM/TD configurations). Choose
`1.x <https://top-maker.github.io/modpoll/1.x/>`_
or `2.x <https://top-maker.github.io/modpoll/v2/>`_.

.. toctree::
:maxdepth: 2
Expand Down
5 changes: 4 additions & 1 deletion docs/site/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ when that happens. The value is still written as asked for.
Configuration File
------------------

The configuration file (`--config`) is a WoT TM/TD JSON file that defines the devices, pollers, and references to be read.
The configuration file (`--config`) defines the devices, pollers, and points
to be read. It can be a WoT TM/TD JSON file or a v1 CSV file; the format is
detected from the content. Use `--thing-model` or
`--thing-description`/`--td` to assert the JSON document kind explicitly.

For register references (i.e., Holding or Input registers) with a ``dtype`` of ``bool``, you can specify a single bit to be extracted from the 16-bit register. This is done by appending ``:bit`` to the address, where ``bit`` is an integer from 0 to 15.

Expand Down
23 changes: 15 additions & 8 deletions docs/site/v1-compatibility.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
v1 compatibility and M3 acceptance
===================================

The v2 change replaces CSV loading with the executable TM/TD profile. The existing
transport, decoder, output and raw write paths remain. This table compares the
pinned v1 baseline ``0b42099`` with the v2 implementation; it is not a claim that
all WoT documents or every operating system has been validated.
The v2 change adds the executable TM/TD profile alongside the retained v1 CSV
loader. ``--config`` detects the format from the content;
``--thing-model``/``--thing-description`` assert the JSON document kind. The
existing transport, decoder, output and raw write paths remain. This table
compares the pinned v1 baseline ``0b42099`` with the v2 implementation; it is
not a claim that all WoT documents or every operating system has been
validated.

.. list-table:: Capability and evidence
:header-rows: 1
Expand All @@ -15,9 +18,11 @@ all WoT documents or every operating system has been validated.
- Evidence / limit
* - Existing CLI
- Existing transport, rate, interval, output and MQTT arguments retained;
``--unit-id`` adds an explicit override.
- ``test_framer_validation.py`` and existing CLI tests. No ``--model`` or
automatic connection from TD Forms is introduced.
``--unit-id`` adds an explicit override. v1 CSV configurations load
through the same ``--config`` argument, detected from the content.
- ``test_framer_validation.py``, ``test_csv_config.py`` and existing CLI
tests. No automatic connection from TM Forms is introduced; a concrete
TD still supplies its endpoint.
* - Multiple devices/configurations
- One Thing per file; split an old multi-device CSV into several JSON files.
Per-file Unit IDs and unique titles are retained.
Expand Down Expand Up @@ -97,7 +102,9 @@ all WoT documents or every operating system has been validated.
Current boundaries
------------------

CSV runtime support is intentionally removed; use :doc:`csv-migration`. Strings
CSV runtime support is retained, so v1 configurations and commands keep
working; new configurations should still prefer profile 0.2 (see
:doc:`csv-migration`). Strings
and bit arrays carrying meaningless numeric scales, invalid rw modes, unknown
types and incomplete payload spans require review rather than silent conversion.
Profile inheritance/templates/actions and new property-based writes are separate
Expand Down
21 changes: 21 additions & 0 deletions docs/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,24 @@ The unified local Compose example was started in an isolated project and deliver
template and duplicate Compose examples were removed; ``examples/modsim.csv``
remains as the explicit migration-test fixture. See ``examples/README.md`` for
the current runnable example.


v1 CSV compatibility restoration
--------------------------------

On 2026-11-12 the v1 CSV loader was restored behind content detection:
``-f``/``--config`` (alias ``--tm``) accepts v1 CSV and WoT TM/TD JSON side by
side, and the new
``--thing-model``/``--thing-description`` flags assert the JSON document kind
(``--tm`` had just been taken by the POLL-02b alias for ``--config``, which
also accepts ``modiohub:`` Workspace references, so the asserting flag is the
long ``--thing-model`` only). A full read stays Thing-Model-only: CSV
configurations are rejected with ``--full-read``. After merging the POLL-02a/02b
release into the branch, ``make check`` passed and the offline suite passed 243
tests with 58
integration tests deselected, including new CSV loader, kind-assertion and
CLI error tests. Against a local modsim process, ``modpoll --once --config
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.
3 changes: 2 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
explicit blocks and 37 properties.
- `modsim.generated.td.json`: its generated local TCP instance for the same
blocks and properties.
- `modsim.csv`: v1 migration and compatibility-test input. v2 does not load it.
- `modsim.csv`: the v1 CSV configuration; v2 loads it again through the same
`--config` content detection and produces the same 37 points as the TM.

From the repository root, run the self-contained TCP/MQTT demonstration:

Expand Down
28 changes: 26 additions & 2 deletions modpoll/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,38 @@ def get_parser():
dest="config",
default=None,
help=(
"Local path or URL of a WoT TM/TD JSON configuration, or "
"Local path or URL of a v1 CSV or WoT TM/TD JSON configuration, or "
"modiohub:<id>@<version> for a custom Thing Model in your ModioHub "
"Workspace (run modpoll login first unless it is shared). "
"Type is detected from content, not the filename. "
"The format is detected from the content, not the filename. "
"Required unless --device is given."
),
nargs="+",
)
parser.add_argument(
"--thing-model",
dest="thing_model",
default=[],
help=(
"Local path or URL of a WoT Thing Model JSON configuration "
"(tm:ThingModel); asserts the document kind instead of detecting it. "
"Not for modiohub: Workspace references; use --config/--tm for those."
),
nargs="+",
metavar="PATH_OR_URL",
)
parser.add_argument(
"--thing-description",
"--td",
dest="thing_description",
default=[],
help=(
"Local path or URL of a WoT Thing Description JSON configuration; "
"asserts the document kind instead of detecting it"
),
nargs="+",
metavar="PATH_OR_URL",
)
parser.add_argument(
"--device",
metavar="MANUFACTURER/MODEL[@COMMIT]",
Expand Down
Loading
Loading