diff --git a/.github/actions/linux-deps/action.yml b/.github/actions/linux-deps/action.yml index 29c8051..284d525 100644 --- a/.github/actions/linux-deps/action.yml +++ b/.github/actions/linux-deps/action.yml @@ -5,13 +5,20 @@ description: >- cached: on a hit they are installed with dpkg, with no apt-get update and no mirror at all. The key includes the runner image version, so the cached .deb files always match the base system. On a miss apt runs with time limits and retries, and the packages it downloaded are saved. +inputs: + extra: + description: More packages for this job (e.g. the E2E's WebKitWebDriver, Xvfb, socat). + required: false + default: "" runs: using: composite steps: - id: key shell: bash + env: + EXTRA: ${{ inputs.extra }} run: | - packages="libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev libudev-dev" + packages="libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev libudev-dev $EXTRA" echo "packages=$packages" >> "$GITHUB_OUTPUT" echo "dir=$HOME/.cache/linux-deps" >> "$GITHUB_OUTPUT" hash=$(printf '%s' "$packages" | sha256sum | cut -c1-16) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d27f6f..5a8cd17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,11 @@ on: permissions: contents: read +# A newer push to the same branch or pull request makes the older run moot. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + env: CARGO_TERM_COLOR: always @@ -121,3 +126,74 @@ jobs: src-tauri/target/release/bundle/deb/*.deb src-tauri/target/release/bundle/appimage/*.AppImage if-no-files-found: error + + # The real app against pymodbus (e2e/run.mjs), on both desktop platforms Tauri can drive. + # Windows has no socat, so its run has no serial checks and says so in its output. + e2e: + needs: [rust, frontend, file-size] + strategy: + fail-fast: false + matrix: + # Not windows-latest: on windows-2025 msedgedriver cannot attach to WebView2 even at matching + # versions ("DevToolsActivePort file doesn't exist", measured here with 156.0.4314.58 on + # 2026-11-06; https://github.com/actions/runner-images/issues/14738, closed upstream). + os: [ubuntu-24.04, windows-2022] + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version-file: .node-version + cache: npm + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 + with: + python-version: "3.12" + - run: python -m pip install pymodbus==3.16.2 + - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable + - uses: Swatinem/rust-cache@e9d7b9f1e587218970671bac74e5511ed9506e6a # v2 + with: + workspaces: src-tauri + shared-key: e2e + save-if: ${{ github.ref == 'refs/heads/master' }} + - name: System dependencies + if: runner.os == 'Linux' + uses: ./.github/actions/linux-deps + timeout-minutes: 30 + with: + extra: webkit2gtk-driver xvfb socat + - run: cargo install tauri-driver --locked --version 2.1.0 + # tauri-driver drives Edge WebView2 through msedgedriver, whose version must match the + # WebView2 on the runner (https://v2.tauri.app/develop/tests/webdriver/ci/). + - name: Edge driver matching WebView2 + if: runner.os == 'Windows' + shell: pwsh + run: | + cargo install --git https://github.com/chippers/msedgedriver-tool + & "$HOME/.cargo/bin/msedgedriver-tool.exe" + $PWD.Path >> $env:GITHUB_PATH + # The driver must match WebView2, which can differ from Edge: print both to compare. + $webview = Get-ItemProperty "HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" -ErrorAction SilentlyContinue + $edge = (Get-Item "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" -ErrorAction SilentlyContinue).VersionInfo.ProductVersion + Write-Output "WebView2 $($webview.pv), Edge $edge, $(& .\msedgedriver.exe --version)" + - run: npm ci + - run: npx tauri build --debug --no-bundle + - name: E2E (Linux) + if: runner.os == 'Linux' + run: xvfb-run -a node e2e/run.mjs + env: + E2E_OUT: ${{ runner.temp }}/e2e + - name: E2E (Windows) + if: runner.os == 'Windows' + run: node e2e/run.mjs + env: + E2E_OUT: ${{ runner.temp }}/e2e + # Failure screenshots and what the webview showed, to read a failure without guessing. + - if: failure() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 + with: + name: e2e-${{ runner.os }} + path: ${{ runner.temp }}/e2e + if-no-files-found: ignore diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..a8cf64d --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,50 @@ +name: Pages + +# The project page at https://chetto1983.github.io/ModbusTool, built from site/ with the app's +# tokens and screenshots. Needs Settings → Pages → Source: GitHub Actions. +on: + push: + branches: [master] + paths: + - site/** + - docs/screenshots/** + - src/app.css + - src/assets/fonts/** + - src-tauri/icons/icon.svg + - scripts/build-site.mjs + - .github/workflows/pages.yml + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7 + with: + node-version-file: .node-version + - run: node scripts/build-site.mjs + - uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6 + - uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5 + with: + path: _site + + deploy: + needs: build + runs-on: ubuntu-24.04 + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index baa78ce..1716dec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -228,3 +228,24 @@ jobs: assets/appimage/*.AppImage assets/appimage/*.AppImage.sig latest.json \ --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" \ --title "ModbusTool $TAG" --notes-file notes.md + + # Updates the package in the Windows Package Manager (docs/publishing.md). It runs once the first + # version is in microsoft/winget-pkgs and the WINGET_TOKEN secret (a classic token with + # public_repo, from the account that forked winget-pkgs) is set; without the secret it skips. + winget: + needs: publish + runs-on: windows-latest + env: + WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }} + steps: + - name: Submit the new version to winget-pkgs + if: env.WINGET_TOKEN != '' + shell: pwsh + run: | + $version = "${env:TAG}".TrimStart("v") + $url = "https://github.com/${env:GITHUB_REPOSITORY}/releases/download/${env:TAG}/ModbusTool_${version}_x64_en-US.msi" + # A pinned release of Microsoft's tool, checked against its hash before it runs. + Invoke-WebRequest https://github.com/microsoft/winget-create/releases/download/v1.12.13.0/wingetcreate.exe -OutFile wingetcreate.exe + $hash = (Get-FileHash wingetcreate.exe -Algorithm SHA256).Hash + if ($hash -ne "24042BD37915805615E6CF969AC57C6439124C3FE85823327F5F3FB24BD9FFEA") { throw "wingetcreate.exe hash $hash" } + .\wingetcreate.exe update chetto1983.ModbusTool --urls $url --version $version --submit --token $env:WINGET_TOKEN diff --git a/.gitignore b/.gitignore index f410c39..e74738a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ reports/ mutants.out*/ # Generated by Paraglide JS from messages/ (npm run i18n, or the Vite plugin). src/paraglide/ +_site/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f667fc..60a0435 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,28 @@ Notable changes to ModbusTool, newest first. Each section is also the text of it [GitHub release](https://github.com/chetto1983/ModbusTool/releases): the Release workflow publishes the section whose heading matches the pushed `vX.Y.Z` tag. The full history is in git. +## v3.4.0 — 2026-11-06 + +A colour for every dashboard variable, from the theme or picked freely, and the end-to-end tests +now run on every change, on Linux and Windows. + +### Added + +- A colour for each dashboard variable: trend line, bar and lamp. Pick one of five theme colours + that follow the light and dark themes, or any custom colour with a colour picker + (color-picker-svelte). Without one, the automatic colours stay as before. + +### Fixed + +- Dashboards on Modbus TCP or UDP: a block of more than 123 neighbouring registers (3.3.1) was + refused by the master, so its values never updated. Blocks now stop at 123 registers on TCP/UDP + and at 125 on the other links, like the polls. + +### Changed + +- The end-to-end tests against an independent Modbus server run in CI on Linux and Windows. On + Windows they cover TCP, UDP and RTU over TCP; the serial checks need socat, which Windows lacks. + ## v3.3.1 — 2026-11-06 Dashboards read neighbouring variables in one request, far less traffic on the device. diff --git a/README.md b/README.md index 828d521..e4d2907 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,18 @@ # ModbusTool -A Modbus **master and slave** tool for Windows and Linux (macOS can be built from source). -Version 3 is a full rewrite of the WinForms tool as a [Tauri](https://tauri.app) desktop app: -Rust backend, Svelte frontend, one window for both roles. +A free, open-source Modbus **master and slave** for Windows and Linux, with live dashboards. +TCP, UDP, RTU, ASCII and RTU over TCP in one window, every common data type and byte order, a +frame-by-frame traffic monitor, and dashboards with trends, gauges, lamps and command panels. -![Master view](docs/screenshots/master-dark.png) +**[⬇ Download the latest release](https://github.com/chetto1983/ModbusTool/releases/latest)**: +Windows `.msi`, Linux `.deb` and `.AppImage` (see [Install](#install)). It updates itself. +Project page: . + +![A dashboard reading a live slave: trend, gauge, lamp and bars](docs/screenshots/dashboard.gif) ## Features -**Links** — Modbus TCP, Modbus UDP, RTU over TCP, RTU serial, ASCII serial. +**Links**: Modbus TCP, Modbus UDP, RTU over TCP, RTU serial, ASCII serial. **Master** - Functions FC01–FC06, FC15, FC16. @@ -23,6 +27,15 @@ Rust backend, Svelte frontend, one window for both roles. - Value generators: sine, ramp, random, square wave. - CSV import/export (also reads the ModbusTool 2 export format `4100:0x04c8,4101:12,...`). +**Dashboards** +- Several named dashboards per project, on a grid you arrange by dragging and resizing panels. +- Panels: trend (steps, straight or smooth lines, zoom), value with gauge and warning/alarm + colours, bars, lamp, button, switch, selector and number input. +- Every panel element reads its own variable (unit, table, address, type, byte order) while the + master is connected; neighbouring registers are read in one request. +- Scaling as SCADA tags do it (raw range to engineering range, both ways), and a colour per + variable from the theme or a colour picker. + **Both** - Data types: UInt16, Int16, Hex, Binary, UInt32, Int32, Float32, UInt64, Int64, Float64, ASCII, with byte orders ABCD, CDAB, BADC, DCBA. Labels per register. @@ -31,9 +44,34 @@ Rust backend, Svelte frontend, one window for both roles. - Projects saved as JSON (`Ctrl+S`, `Ctrl+O`). Dark and light theme, same design as Aura. - Interface in English and Italian, chosen in the sidebar. -| Slave | Traffic monitor | -|---|---| -| ![Slave](docs/screenshots/slave-dark.png) | ![Traffic](docs/screenshots/traffic-dark.png) | +| Master | Slave | Traffic monitor | +|---|---|---| +| ![Master](docs/screenshots/master-dark.png) | ![Slave](docs/screenshots/slave-dark.png) | ![Traffic](docs/screenshots/traffic-dark.png) | + +## How it compares + +| | **ModbusTool** | Modbus Poll + Modbus Slave | ModbusTools (serhmarch) | QModMaster | mbpoll | Simply Modbus | +|---|---|---|---|---|---|---| +| Price | Free (MIT) | USD 129 each | Free (GPL-3.0) | Free (GPL/LGPL-3.0) | Free (GPL-3.0) | From USD 60 per tool | +| Windows / Linux / macOS | ✓ / ✓ / from source | ✓ / – / – | ✓ / ✓ / – | ✓ / ✓ / – | ✓ / ✓ / ✓ | ✓ / – / – | +| Interface | Desktop app | Desktop app | Desktop app | Desktop app | Command line | Desktop app | +| Master and slave | One app | Two products | Two apps | Master only | Master only | Separate products | +| TCP · UDP · RTU · ASCII · RTU over TCP | ✓ · ✓ · ✓ · ✓ · ✓ | ✓ · ✓ · ✓ · ✓ · ✓ | ✓ · ✓ · ✓ · ✓ · ✓ | ✓ · – · ✓ · – · – | ✓ · – · ✓ · – · – | ✓ · – · ✓ · ✓ · ✓ | +| 64-bit integers and doubles, 4 byte orders | ✓ | ✓ | ✓ | – | – (32-bit only) | – | +| Traffic monitor | ✓ | ✓ | ✓ | ✓ | – | Log file | +| Trend charts | ✓ | ✓ | – | – | – | – | +| Dashboards with commands | ✓ | – | – | – | – | – | +| Auto-update | ✓ | – | – | – | – | – | + +– means not offered, or not stated by the project. Checked on 2026-11-06 against each project's +own site or repository: [Modbus Poll](https://www.modbustools.com/modbus_poll.html) and +[Modbus Slave](https://www.modbustools.com/modbus_slave.html) +([prices](https://www.modbustools.com/order.html)), +[ModbusTools](https://github.com/serhmarch/ModbusTools), +[QModMaster](https://sourceforge.net/projects/qmodmaster/), +[mbpoll](https://github.com/epsilonrt/mbpoll), +[Simply Modbus](https://www.simplymodbus.ca/tools.html) ([prices](https://www.simplymodbus.ca/purchase.html)). +Corrections are welcome as issues. ## Install @@ -111,7 +149,9 @@ cd src-tauri && cargo fmt --check && cargo clippy --all-targets -- -D warnings & ``` End-to-end run of the real app against [pymodbus](https://github.com/pymodbus-dev/pymodbus) as an -independent implementation (Linux; needs `tauri-driver`, `WebKitWebDriver`, `socat`, `pymodbus`): +independent implementation. CI runs it on Linux and Windows (Windows without the serial checks, +which need `socat`). Locally on Linux it needs `tauri-driver`, `WebKitWebDriver`, `socat` and +`pymodbus`: ```sh npx tauri build --debug --no-bundle diff --git a/docs/publishing.md b/docs/publishing.md new file mode 100644 index 0000000..994ed25 --- /dev/null +++ b/docs/publishing.md @@ -0,0 +1,78 @@ +# Publishing to winget and Flathub + +Both stores take a package through a pull request from the maintainer's GitHub account to a +repository they own (`microsoft/winget-pkgs`, `flathub/flathub`). This repository holds what those +pull requests need; opening them is the maintainer's step. + +## winget (Windows Package Manager) + +Package identifier: `chetto1983.ModbusTool`. Installer: the release's MSI +(`ModbusTool__x64_en-US.msi`, publisher `chetto1983` from 3.4.0). + +**First submission, by hand on Windows** (winget-pkgs reviews the first version of a package): + +```powershell +winget install Microsoft.WingetCreate +wingetcreate new https://github.com/chetto1983/ModbusTool/releases/download/v3.4.0/ModbusTool_3.4.0_x64_en-US.msi +``` + +`wingetcreate new` reads the MSI (product code, version, publisher) and asks for the rest. Give: + +- Package identifier `chetto1983.ModbusTool` +- License `MIT`, license URL `https://github.com/chetto1983/ModbusTool/blob/master/LICENSE` +- Short description `Modbus master and slave with live dashboards` + +At the end, answer yes to submitting. It forks `winget-pkgs` under your account and opens the pull +request. A bot validates it and runs the installer in a sandbox. Unsigned MSIs are accepted, but +SmartScreen still warns when the installer runs. + +**Later versions, automatic**: the `winget` job of the Release workflow submits each new version +with `wingetcreate update`. It needs a repository secret `WINGET_TOKEN`: a classic personal access +token with the `public_repo` scope, from the account that holds the `winget-pkgs` fork. Without +the secret the job does nothing. The job downloads a pinned `wingetcreate` and checks its SHA-256 +before running it. + +## Flathub + +App id: `io.github.chetto1983.modbustool`, the same as `identifier` in `tauri.conf.json`. Flathub +verifies an `io.github.` id against the GitHub account of the same name. + +Files in `packaging/flatpak/`: + +| File | Checked | +|---|---| +| `io.github.chetto1983.modbustool.metainfo.xml` | `appstreamcli validate --no-net`: passes | +| `io.github.chetto1983.modbustool.desktop` | `desktop-file-validate`: passes | +| `io.github.chetto1983.modbustool.yml` | **Not built yet.** It follows the open-source path of the [Tauri Flathub guide](https://v2.tauri.app/distribute/flatpak/); `flatpak-builder` was not available where it was written | + +**Before submitting**: + +1. **Turn off the self-updater inside Flatpak.** Flathub updates the app. The in-app updater would + download the AppImage from the GitHub release instead, so it has to be disabled when the app + runs in a Flatpak (the `FLATPAK_ID` environment variable is set there). This is a code change + and is not done yet. +2. **Pick the GNOME runtime.** The manifest uses `47`, the Tauri guide's version. Use a runtime + Flathub still supports that ships `webkit2gtk-4.1`, and update `runtime-version`. +3. **Generate the offline sources.** The Flatpak build has no network. Generate them with + [flatpak-builder-tools](https://github.com/flatpak/flatpak-builder-tools) at the tag being + published: + + ```sh + python3 flatpak-builder-tools/cargo/flatpak-cargo-generator.py src-tauri/Cargo.lock -o cargo-sources.json + flatpak-node-generator npm package-lock.json -o node-sources.json + ``` + +4. **Build and run it locally**, then fix what fails: + + ```sh + flatpak-builder --force-clean --user --install-deps-from=flathub --repo=repo build \ + packaging/flatpak/io.github.chetto1983.modbustool.yml + flatpak-builder --run build packaging/flatpak/io.github.chetto1983.modbustool.yml modbus-tool + ``` + + Check that TCP, UDP and a USB serial adapter all work from inside the sandbox. + +**Submitting** (from the [Tauri guide](https://v2.tauri.app/distribute/flatpak/)): fork +`flathub/flathub`, clone the `new-pr` branch, add the manifest and the two generated JSON files on +a branch named after the app, and open a pull request against `new-pr`. After the review, Flathub +gives you a repository for the app, where later versions are updated. diff --git a/docs/screenshots/dashboard.gif b/docs/screenshots/dashboard.gif new file mode 100644 index 0000000..dd0d6b3 Binary files /dev/null and b/docs/screenshots/dashboard.gif differ diff --git a/docs/superpowers/plans/2026-11-06-dashboards.md b/docs/superpowers/plans/2026-11-06-dashboards.md index 0c602d2..38acace 100644 --- a/docs/superpowers/plans/2026-11-06-dashboards.md +++ b/docs/superpowers/plans/2026-11-06-dashboards.md @@ -64,3 +64,9 @@ lo storico non cresce senza limite; gridstack e Svelte non si contendono il DOM. - [x] **T11 Blocchi di lettura**: blocchi di variabili contigue per unit, tabella e periodo; un poll del backend per blocco; valori e storico di ogni variabile presi dal suo blocco; test (blocchi, limiti 125/2000, nessun buco letto); misura delle richieste prima e dopo contro pymodbus. + +## Colore delle variabili (spec D22) + +- [x] **T12 Colore**: `colour` sulla variabile (validazione, conversione dei file senza), colori + fissi dai token e personalizzato con color-picker-svelte; trend, barre e lampada; test; E2E + (lampada accesa nel colore scelto). diff --git a/docs/superpowers/specs/2026-11-06-dashboards-design.md b/docs/superpowers/specs/2026-11-06-dashboards-design.md index 634bfde..b70022f 100644 --- a/docs/superpowers/specs/2026-11-06-dashboards-design.md +++ b/docs/superpowers/specs/2026-11-06-dashboards-design.md @@ -61,7 +61,13 @@ Si riprende il modello d'uso, non il codice (React). | # | Decisione | Fonte | |---|---|---| -| D21 | Le variabili con stessa unit, tabella e periodo, **contigue o sovrapposte**, si leggono in **un'unica richiesta** (al massimo 125 registri o 2000 bit, i limiti di FC03/04 e FC01/02, Modbus Application Protocol 1.1b3 §6.1–6.4). Non si leggono indirizzi che nessuna variabile chiede: un dispositivo con un buco nella mappa risponde con l'eccezione 02 all'intero blocco | Calcolo dalla specifica: in RTU a 9600 baud un carattere dura 11/9600 s ≈ 1,15 ms e la pausa tra frame 3,5 caratteri ≈ 4 ms (Modbus over Serial Line 1.02 §2.5.1.1). Una lettura di un registro (8 + 7 byte) costa ≈ 25 ms, quindi 30 variabili ≈ 750 ms, più di un periodo da 200 ms. Misurato solo il numero di richieste e la correttezza dei valori: le pty di socat non hanno i tempi della seriale | +| D21 | Le variabili con stessa unit, tabella e periodo, **contigue o sovrapposte**, si leggono in **un'unica richiesta** (al massimo 2000 bit e 125 registri, i limiti di FC01/02 e FC03/04, Modbus Application Protocol 1.1b3 §6.1–6.4; **123 registri su TCP/UDP**, dove rmodbus limita il frame a 255 byte, come per i poll: emendato 2026-11-06, la 3.3.1 usava 125 e il master rifiutava il blocco). Non si leggono indirizzi che nessuna variabile chiede: un dispositivo con un buco nella mappa risponde con l'eccezione 02 all'intero blocco | Calcolo dalla specifica: in RTU a 9600 baud un carattere dura 11/9600 s ≈ 1,15 ms e la pausa tra frame 3,5 caratteri ≈ 4 ms (Modbus over Serial Line 1.02 §2.5.1.1). Una lettura di un registro (8 + 7 byte) costa ≈ 25 ms, quindi 30 variabili ≈ 750 ms, più di un periodo da 200 ms. Misurato solo il numero di richieste e la correttezza dei valori: le pty di socat non hanno i tempi della seriale | + +## Colore delle variabili (2026-11-06, richiesta utente) + +| # | Decisione | Fonte | +|---|---|---| +| D22 | Ogni variabile può avere un **colore**: linea del trend, barra, lampada accesa. **Fissi**: cinque token Aura che seguono il tema (ring, success, warning, danger, text-muted; accent è quasi invisibile sul tema scuro, info coincide con ring sul chiaro). **Personalizzato**: un esadecimale scelto con `color-picker-svelte` 2.0.4 (MIT, Svelte 5, dipendenza `@ctrl/tinycolor` MIT). Nessun colore: la palette automatica per posizione, come prima. Nel file: `null`, il nome del token o `#rrggbb` | Richiesta utente con il playground di `color-picker-svelte`; inventario del pacchetto pubblicato | ## Cosa NON è dimostrato diff --git a/docs/superpowers/verification/2026-11-06-dashboards.md b/docs/superpowers/verification/2026-11-06-dashboards.md index f2f291b..9b8794f 100644 --- a/docs/superpowers/verification/2026-11-06-dashboards.md +++ b/docs/superpowers/verification/2026-11-06-dashboards.md @@ -81,8 +81,25 @@ Data: 2026-11-06. Spec: `docs/superpowers/specs/2026-11-06-dashboards-design.md` - posizione di ogni variabile nel suo blocco; - un'eccezione sul blocco segna come non aggiornate tutte le sue variabili. +## Colore delle variabili (D22), misurato il 2026-11-06 + +- **E2E** 88/88: la lampada "Running" impostata su Rosso si accende col colore calcolato del + token `--color-danger`. +- **Screenshot** dell'editor (tema scuro): + - campioni Automatico e cinque colori fissi, con il selezionato evidenziato; + - il personalizzato apre il selettore di color-picker-svelte con l'esadecimale. + + Il primo screenshot ha trovato un difetto del pacchetto 2.0.4: con `Position.Auto` il popup si + apre sempre sotto, perché `showAbove` non restituisce il risultato. Veniva tagliato dal fondo + della finestra di modifica. Ora la posizione si sceglie in base allo spazio nella finestra, e lo + screenshot dopo la correzione mostra il popup sopra, intero. +- **Unit test**: colori accettati e rifiutati nel file, risoluzione token/esadecimale/automatico, + colore conservato quando lo stato segue il target. + ## Cosa NON dimostra +- Il colore delle linee del trend e delle barre: verificato solo a vista nell'editor; l'E2E + controlla la lampada. - Il gauge nel tema scuro e su WebView2: provato solo in WebKitGTK, tema chiaro. - WebView2 su Windows: trascinamento, selettore e input numerico vanno provati a mano. - Il ridimensionamento dei pannelli (nessun controllo E2E). diff --git a/e2e/dashboard.mjs b/e2e/dashboard.mjs index 83bdaf5..14f68fa 100644 --- a/e2e/dashboard.mjs +++ b/e2e/dashboard.mjs @@ -93,7 +93,10 @@ export async function dashboardScenario(browser, target) { await period.clearValue(); await period.setValue("200"); await addPanel(browser, "Value", { Title: "Pressure", Address: 2, "Unit of measure": "bar", Decimals: 0 }); - await addPanel(browser, "Lamp", { Title: "Running", "Read from": "Coils", Address: 0 }); + await click(browser, button("", "Add panel")); + await click(browser, button(dialog, "Lamp")); + await click(browser, `${dialog}//button[@aria-label='Red']`); + await saveDialog(browser, { Title: "Running", "Read from": "Coils", Address: 0 }); await addPanel(browser, "Button", { Title: "Set 4242", Address: 5, "Value to write": "4242" }); // The state of a command is read at first from the address it writes. await addPanel(browser, "Switch", { Title: "Valve 7" }, 7); @@ -151,6 +154,16 @@ export async function dashboardScenario(browser, target) { await eventually(async () => { if (!(await lamp.getAttribute("class")).includes("on")) throw new Error("lamp off"); }, "lamp"); + // Lit in the colour chosen for its variable: the theme's danger red. + const [lit, red] = await browser.execute((el) => { + const probe = document.createElement("i"); + probe.style.color = "var(--color-danger)"; + document.body.append(probe); + const colours = [getComputedStyle(el).backgroundColor, getComputedStyle(probe).color]; + probe.remove(); + return colours; + }, lamp); + expectEqual(lit, red, "lamp colour"); }); await check("Dashboard: a button writes its value (FC06) to the reference", async () => { diff --git a/e2e/helpers.mjs b/e2e/helpers.mjs index 38b5c1b..af1475f 100644 --- a/e2e/helpers.mjs +++ b/e2e/helpers.mjs @@ -2,13 +2,23 @@ // WebDriver UI helpers (see run.mjs). import { execFileSync } from "node:child_process"; -import { mkdtempSync } from "node:fs"; +import { mkdirSync, mkdtempSync } from "node:fs"; import { tmpdir } from "node:os"; import { join, resolve } from "node:path"; import { setTimeout as sleep } from "node:timers/promises"; export const root = resolve(import.meta.dirname, ".."); -export const tmp = mkdtempSync(join(tmpdir(), "modbustool-e2e-")); +/** Windows names the interpreter `python`; elsewhere `python3` is the one with pymodbus. */ +export const python = process.platform === "win32" ? "python" : "python3"; +/** + * Serial checks need socat's pty pairs, which Windows does not have: there they are not run, and + * the run says so, rather than counting them as passed. + */ +export const serial = process.platform !== "win32"; +/** Failure screenshots and the run's files; E2E_OUT names a folder CI uploads when a run fails. */ +export const tmp = process.env.E2E_OUT + ? (mkdirSync(process.env.E2E_OUT, { recursive: true }), process.env.E2E_OUT) + : mkdtempSync(join(tmpdir(), "modbustool-e2e-")); export const results = []; let currentBrowser = null; @@ -18,7 +28,7 @@ export function track(browser) { } export function reference(...args) { - const out = execFileSync("python3", [join(root, "e2e/reference_client.py"), ...args.map(String)], { + const out = execFileSync(python, [join(root, "e2e/reference_client.py"), ...args.map(String)], { encoding: "utf8", }); return JSON.parse(out.trim().split("\n").pop()); @@ -74,12 +84,20 @@ export async function setField(browser, scope, label, value) { } } -export async function click(browser, xpath) { - const el = await browser.$(xpath); +/** + * Scrolls the element into view first, as a user would: on the Windows runner the desktop is + * 1024×768, the window is clamped to it, and rows of a scrolled grid are outside the viewport. + */ +async function clickElement(el) { await el.waitForClickable({ timeout: 5000 }); + await el.scrollIntoView({ block: "center" }); await el.click(); } +export async function click(browser, xpath) { + await clickElement(await browser.$(xpath)); +} + export const button = (scope, text) => `${scope}//button[normalize-space()="${text}"]`; export const labelled = (label) => `//button[@aria-label="${label}"]`; export const dialog = "//dialog[@open]"; @@ -96,14 +114,19 @@ export async function editPoll(browser, fields) { await saveDialog(browser, fields); } +/** + * The value column. textContent, not getText: WebDriver's text is empty for a cell its scrolled grid + * keeps out of view, which happens in the short window of the Windows runner. + */ export async function gridValues(browser) { - return browser.$$("//div[@role='row' and contains(@class,'line')]/span[@role='cell'][4]").map((c) => c.getText()); + return browser + .$$("//div[@role='row' and contains(@class,'line')]/span[@role='cell'][4]") + .map(async (c) => (await c.getProperty("textContent")).trim()); } export async function editCell(browser, index, value) { const cell = await browser.$(`(//div[contains(@class,'line')]//button[contains(@class,'cell')])[${index + 1}]`); - await cell.waitForClickable({ timeout: 5000 }); - await cell.click(); + await clickElement(cell); const input = await browser.$("input.edit"); await input.waitForExist({ timeout: 3000 }); // setValue would run WebDriver "Element Clear", which blurs the input and cancels the edit. diff --git a/e2e/reference_servers.py b/e2e/reference_servers.py index 5f28327..47d5be7 100644 --- a/e2e/reference_servers.py +++ b/e2e/reference_servers.py @@ -1,6 +1,7 @@ """Independent reference: pymodbus servers the app's master talks to during E2E. -Usage: python3 reference_servers.py +Usage: python3 reference_servers.py [serial_device] +Without a serial device (Windows has no socat ptys) only the network servers run. Unit 1: holding register n = 111 * (n + 1), input register n = 1000 + n, even coils ON. pymodbus data blocks start at 1 for protocol address 0. """ @@ -24,14 +25,16 @@ def context() -> ModbusServerContext: async def main() -> None: - tcp, udp, rtu_over_tcp, serial = int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]), sys.argv[4] + tcp, udp, rtu_over_tcp = int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]) shared = context() - await asyncio.gather( + servers = [ StartAsyncTcpServer(shared, address=("127.0.0.1", tcp)), StartAsyncUdpServer(shared, address=("127.0.0.1", udp)), StartAsyncTcpServer(shared, address=("127.0.0.1", rtu_over_tcp), framer=FramerType.RTU), - StartAsyncSerialServer(shared, port=serial, framer=FramerType.ASCII, baudrate=19200), - ) + ] + if len(sys.argv) > 4: + servers.append(StartAsyncSerialServer(shared, port=sys.argv[4], framer=FramerType.ASCII, baudrate=19200)) + await asyncio.gather(*servers) asyncio.run(main()) diff --git a/e2e/run.mjs b/e2e/run.mjs index 1b8b874..1493dde 100644 --- a/e2e/run.mjs +++ b/e2e/run.mjs @@ -1,13 +1,15 @@ -// End-to-end run of the real app (tauri-driver + WebKitWebDriver) against pymodbus as an -// independent reference implementation. Linux only (tauri-driver has no macOS driver). +// End-to-end run of the real app (tauri-driver) against pymodbus as an independent reference +// implementation, on Linux (WebKitWebDriver) and Windows (msedgedriver matching WebView2). +// tauri-driver has no macOS driver. // // npx tauri build --debug --no-bundle && node e2e/run.mjs [screenshot-dir] // -// Needs: tauri-driver, WebKitWebDriver, socat, python3 with pymodbus, an X display. +// Needs: tauri-driver, the platform's WebDriver, python with pymodbus; on Linux also socat (the +// serial checks) and an X display. Windows runs every check but the serial ones. import { remote } from "webdriverio"; import { spawn } from "node:child_process"; -import { mkdirSync } from "node:fs"; +import { mkdirSync, openSync, readFileSync } from "node:fs"; import { join, resolve } from "node:path"; import { setTimeout as sleep } from "node:timers/promises"; import { @@ -22,10 +24,12 @@ import { gridValues, labelled, panel, + python, reference, results, root, saveDialog, + serial, setField, tmp, track, @@ -33,11 +37,15 @@ import { import { dashboardScenario } from "./dashboard.mjs"; import { typesMaster, typesSlave } from "./types.mjs"; +const APP = process.platform === "win32" ? "modbus-tool.exe" : "modbus-tool"; const shots = process.argv[2] ? resolve(process.argv[2]) : null; const children = []; +// What tauri-driver, the native WebDriver, the app and its webview print: read when the app fails to start. +const driverLog = join(tmp, "tauri-driver.log"); -function background(command, args) { - const child = spawn(command, args, { stdio: "ignore" }); +function background(command, args, log) { + const out = log ? openSync(log, "w") : "ignore"; + const child = spawn(command, args, { stdio: ["ignore", out, out] }); children.push(child); return child; } @@ -50,11 +58,78 @@ async function screenshot(browser, name) { // ---------- scenario ---------- +/** + * The app has started once its theme is set. A cold start on a fresh CI runner takes longer than + * the 5 s default; when it never starts, what the webview shows is kept for the CI artifact. + */ +async function whenStarted(browser) { + try { + await browser.waitUntil(async () => Boolean(await browser.execute(() => document.documentElement.dataset.theme)), { + timeout: 30_000, + }); + } catch (e) { + await browser.saveScreenshot(join(tmp, "not-started.png")).catch(() => {}); + const state = await browser + .execute(() => ({ + url: location.href, + ready: document.readyState, + agent: navigator.userAgent, + body: document.body?.innerHTML.slice(0, 800), + // A module script waits for the stylesheets before it: was the one before it loaded? + stylesheet: (() => { + try { + return `${document.styleSheets[0]?.cssRules.length} rules`; + } catch (err) { + return String(err); + } + })(), + })) + .catch((err) => ({ error: String(err) })); + // Importing the app's module again surfaces the error that stopped it, if it threw. If the app + // mounts after it, the first load of the bundle never ran. + const load = await browser + .execute(async () => { + const src = document.querySelector("script[type=module]")?.getAttribute("src"); + if (!src) return "no module script"; + try { + await import(src); + await new Promise((done) => requestAnimationFrame(done)); + return `module ${src} loaded; theme after it: ${document.documentElement.dataset.theme ?? "none"}`; + } catch (err) { + return `module ${src}: ${err?.stack ?? err}`; + } + }) + .catch((err) => `import check failed: ${err}`); + // Whether the app's protocol answers requests for the page's own files now. + const fetched = await browser + .execute(async () => { + const urls = [...document.querySelectorAll("script[src], link[href]")].map((tag) => tag.src || tag.href); + return Promise.all( + urls.map(async (url) => { + const answer = await Promise.race([ + fetch(url).then( + (r) => `${r.status} ${r.headers.get("content-type")}`, + (err) => String(err), + ), + new Promise((done) => setTimeout(() => done("no answer in 5 s"), 5000)), + ]); + return `${url}: ${answer}`; + }), + ); + }) + .catch((err) => `fetch check failed: ${err}`); + console.error("Fetch:", fetched); + console.error("Module:", load); + console.error("App not started:", JSON.stringify(state)); + console.error("tauri-driver output (last 4 KB):\n" + readFileSync(driverLog, "utf8").slice(-4096)); + throw e; + } +} + async function masterScenario(browser, ports, serialRef) { const conn = panel("Connection"); console.log("Master against pymodbus"); // The theme persists across runs; start from the dark one so screenshots are comparable. - await browser.waitUntil(async () => Boolean(await browser.execute(() => document.documentElement.dataset.theme))); if ((await browser.execute(() => document.documentElement.dataset.theme)) === "light") { await click(browser, "//nav//button[contains(@class,'theme')]"); } @@ -129,7 +204,7 @@ async function masterScenario(browser, ports, serialRef) { const others = [ ["UDP", "Modbus UDP", { Port: ports.udp }], ["RTU over TCP", "RTU over TCP", { Port: ports.rtuOverTcp }], - ["ASCII serial", "ASCII · serial", { "Serial port": serialRef, "Data bits": "8" }], + ...(serial ? [["ASCII serial", "ASCII · serial", { "Serial port": serialRef, "Data bits": "8" }]] : []), ]; for (const [name, protocol, fields] of others) { await check(`${name}: read once FC04 matches the reference`, async () => { @@ -215,7 +290,7 @@ async function slaveScenario(browser, ports, slaveSerial, clientSerial) { { Port: ports.slaveRtuOverTcp }, ["rtuovertcp", `127.0.0.1:${ports.slaveRtuOverTcp}`], ], - ["RTU serial", "RTU · serial", { "Serial port": slaveSerial }, ["rtu", clientSerial]], + ...(serial ? [["RTU serial", "RTU · serial", { "Serial port": slaveSerial }, ["rtu", clientSerial]]] : []), ]; for (const [name, protocol, fields, client] of others) { await check(`${name}: reference reads FC03 from the slave`, async () => { @@ -285,27 +360,32 @@ async function main() { const ports = { tcp: 15020, udp: 15022, rtuOverTcp: 15021, slaveTcp: 15030, slaveUdp: 15031, slaveRtuOverTcp: 15032 }; const pty = (a, b) => background("socat", [`pty,raw,echo=0,link=${join(tmp, a)}`, `pty,raw,echo=0,link=${join(tmp, b)}`]); - pty("refA", "refB"); - pty("slaveA", "slaveB"); - await sleep(800); - background("python3", [ + if (serial) { + pty("refA", "refB"); + pty("slaveA", "slaveB"); + await sleep(800); + } else { + console.log("Not run on this platform (no socat): ASCII serial master, RTU serial slave\n"); + } + background(python, [ join(root, "e2e/reference_servers.py"), ports.tcp, ports.udp, ports.rtuOverTcp, - join(tmp, "refA"), + ...(serial ? [join(tmp, "refA")] : []), ]); - background("tauri-driver", []); + background("tauri-driver", [], driverLog); await sleep(2000); const browser = await remote({ hostname: "127.0.0.1", port: 4444, logLevel: "error", - capabilities: { "tauri:options": { application: join(root, "src-tauri/target/debug/modbus-tool") } }, + capabilities: { "tauri:options": { application: join(root, "src-tauri/target/debug", APP) } }, }); track(browser); try { + await whenStarted(browser); await masterScenario(browser, ports, join(tmp, "refB")); await slaveScenario(browser, ports, join(tmp, "slaveA"), join(tmp, "slaveB")); await trafficScenario(browser); diff --git a/e2e/types.mjs b/e2e/types.mjs index ca00dde..3882f06 100644 --- a/e2e/types.mjs +++ b/e2e/types.mjs @@ -12,12 +12,13 @@ import { eventually, expectEqual, gridValues, + python, reference, root, setField, } from "./helpers.mjs"; -const groups = JSON.parse(execFileSync("python3", [join(root, "e2e/typed_values.py")], { encoding: "utf8" })); +const groups = JSON.parse(execFileSync(python, [join(root, "e2e/typed_values.py")], { encoding: "utf8" })); function shows(text, expect) { if (expect.kind === "text") return text === expect.text; diff --git a/knip.json b/knip.json index bf2c470..51fecf5 100644 --- a/knip.json +++ b/knip.json @@ -1,5 +1,6 @@ { "$schema": "https://unpkg.com/knip@6/schema.json", + "entry": ["site/site.js"], "ignoreExportsUsedInFile": true, "ignoreDependencies": ["@inlang/plugin-message-format", "@inlang/plugin-m-function-matcher"] } diff --git a/messages/en.json b/messages/en.json index c590cb3..96af790 100644 --- a/messages/en.json +++ b/messages/en.json @@ -101,6 +101,14 @@ "scaling_eng_max": "Engineering max", "scaling_clamp": "Keep to the engineering range", "scaling_same_ends": "The two ends must differ", + "colour_label": "Colour", + "colour_auto": "Automatic", + "colour_custom": "Custom", + "colour_blue": "Blue", + "colour_green": "Green", + "colour_amber": "Amber", + "colour_red": "Red", + "colour_grey": "Grey", "panel_options": "Options", "panel_option_label": "Label", "panel_add_option": "Add option", diff --git a/messages/it.json b/messages/it.json index 7b8d343..05ea6d5 100644 --- a/messages/it.json +++ b/messages/it.json @@ -101,6 +101,14 @@ "scaling_eng_max": "Ingegneristico max", "scaling_clamp": "Limita all'intervallo ingegneristico", "scaling_same_ends": "I due estremi devono essere diversi", + "colour_label": "Colore", + "colour_auto": "Automatico", + "colour_custom": "Personalizzato", + "colour_blue": "Blu", + "colour_green": "Verde", + "colour_amber": "Ambra", + "colour_red": "Rosso", + "colour_grey": "Grigio", "panel_options": "Opzioni", "panel_option_label": "Etichetta", "panel_add_option": "Aggiungi opzione", diff --git a/package-lock.json b/package-lock.json index 987cdac..9208eaa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "modbus-tool", - "version": "3.3.1", + "version": "3.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "modbus-tool", - "version": "3.3.1", + "version": "3.4.0", "license": "MIT", "dependencies": { "@tauri-apps/api": "^2.12.4", @@ -14,6 +14,7 @@ "@tauri-apps/plugin-fs": "^2.7.1", "@tauri-apps/plugin-process": "^2.4.0", "@tauri-apps/plugin-updater": "^2.14.1", + "color-picker-svelte": "^2.0.4", "gridstack": "^14.0.0", "svelte-gauge": "^2.0.2", "uplot": "^1.6.32" @@ -1536,6 +1537,15 @@ "node": ">=0.1.90" } }, + "node_modules/@ctrl/tinycolor": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-4.2.2.tgz", + "integrity": "sha512-9rQHijqB2Rq6qOEC/xHaA6aPlsKGi5kmCQW50O1asn9g63XFeD5NmBwysriistW5Xx0JPafyD/TA7yk2S3pXGQ==", + "license": "MIT", + "engines": { + "node": ">=14" + } + }, "node_modules/@emnapi/core": { "version": "1.11.2", "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.2.tgz", @@ -5715,6 +5725,18 @@ "dev": true, "license": "MIT" }, + "node_modules/color-picker-svelte": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/color-picker-svelte/-/color-picker-svelte-2.0.4.tgz", + "integrity": "sha512-dbNw4xpmA03eADeZJlY0+b/Gm6eJgnrZTuaPZgjA7DxHOcEWfIf3nOz/Kv/FBZ45odDZQe/nZKKB62HpH3Okyg==", + "license": "MIT", + "dependencies": { + "@ctrl/tinycolor": "^4.0.0" + }, + "peerDependencies": { + "svelte": "^5.0.0" + } + }, "node_modules/colors": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", diff --git a/package.json b/package.json index e999c9b..a0179c6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "modbus-tool", "private": true, - "version": "3.3.1", + "version": "3.4.0", "license": "MIT", "type": "module", "scripts": { @@ -55,6 +55,7 @@ "@tauri-apps/plugin-fs": "^2.7.1", "@tauri-apps/plugin-process": "^2.4.0", "@tauri-apps/plugin-updater": "^2.14.1", + "color-picker-svelte": "^2.0.4", "gridstack": "^14.0.0", "svelte-gauge": "^2.0.2", "uplot": "^1.6.32" diff --git a/packaging/flatpak/io.github.chetto1983.modbustool.desktop b/packaging/flatpak/io.github.chetto1983.modbustool.desktop new file mode 100644 index 0000000..cf5f361 --- /dev/null +++ b/packaging/flatpak/io.github.chetto1983.modbustool.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Name=ModbusTool +GenericName=Modbus master and slave +Comment=Test Modbus devices: master, slave, traffic monitor and live dashboards +Exec=modbus-tool +Icon=io.github.chetto1983.modbustool +Terminal=false +Categories=Development;Electronics;Engineering; +Keywords=Modbus;PLC;SCADA;RTU;TCP;serial; diff --git a/packaging/flatpak/io.github.chetto1983.modbustool.metainfo.xml b/packaging/flatpak/io.github.chetto1983.modbustool.metainfo.xml new file mode 100644 index 0000000..7d2d264 --- /dev/null +++ b/packaging/flatpak/io.github.chetto1983.modbustool.metainfo.xml @@ -0,0 +1,59 @@ + + + io.github.chetto1983.modbustool + ModbusTool + Modbus master and slave with live dashboards + CC0-1.0 + MIT + + chetto1983 + + +

+ ModbusTool tests and simulates Modbus devices: a master that reads and writes them and a + slave that answers like one, in a single window. +

+
    +
  • Modbus TCP, UDP, RTU over TCP, RTU and ASCII on serial ports
  • +
  • Integers, floats and 64-bit values in every byte order
  • +
  • A frame-by-frame traffic monitor with decoded descriptions
  • +
  • Dashboards with trends, gauges, lamps, buttons and setpoints, scaled like SCADA tags
  • +
  • Value generators on the slave: sine, ramp, random and square wave
  • +
+
+ io.github.chetto1983.modbustool.desktop + https://github.com/chetto1983/ModbusTool + https://github.com/chetto1983/ModbusTool/issues + https://github.com/chetto1983/ModbusTool + + + The master reading a device + https://raw.githubusercontent.com/chetto1983/ModbusTool/master/docs/screenshots/master-dark.png + + + The slave with value generators + https://raw.githubusercontent.com/chetto1983/ModbusTool/master/docs/screenshots/slave-dark.png + + + The traffic monitor + https://raw.githubusercontent.com/chetto1983/ModbusTool/master/docs/screenshots/traffic-dark.png + + + + + #d7e7ff + #1f3760 + + + + +

Dashboards read neighbouring variables in one request.

+
+
+ + +

Dashboards read their own variables, with SCADA-style scaling, trend lines and zoom, and gauges.

+
+
+
+
diff --git a/packaging/flatpak/io.github.chetto1983.modbustool.yml b/packaging/flatpak/io.github.chetto1983.modbustool.yml new file mode 100644 index 0000000..053cd1c --- /dev/null +++ b/packaging/flatpak/io.github.chetto1983.modbustool.yml @@ -0,0 +1,52 @@ +# Flathub manifest, built from source as the Tauri guide's open-source path does +# (https://v2.tauri.app/distribute/flatpak/). Not built in this repository's CI: see +# docs/publishing.md for what is checked and what has to be done before submitting. +id: io.github.chetto1983.modbustool +runtime: org.gnome.Platform +# The Tauri guide's version; check it is still a supported GNOME runtime that ships +# webkit2gtk-4.1 before submitting (docs/publishing.md). +runtime-version: "47" +sdk: org.gnome.Sdk +command: modbus-tool +finish-args: + - --socket=wayland + - --socket=fallback-x11 + - --device=dri + - --share=ipc + # Modbus TCP, UDP and RTU over TCP. + - --share=network + # Serial ports (/dev/ttyUSB*, /dev/ttyACM*, /dev/ttyS*) for RTU and ASCII. + - --device=all +sdk-extensions: + - org.freedesktop.Sdk.Extension.node22 + - org.freedesktop.Sdk.Extension.rust-stable +build-options: + append-path: /usr/lib/sdk/node22/bin:/usr/lib/sdk/rust-stable/bin +modules: + - name: modbus-tool + buildsystem: simple + env: + CARGO_HOME: /run/build/modbus-tool/cargo + XDG_CACHE_HOME: /run/build/modbus-tool/flatpak-node/cache + npm_config_cache: /run/build/modbus-tool/flatpak-node/npm-cache + npm_config_offline: "true" + sources: + - type: git + url: https://github.com/chetto1983/ModbusTool.git + tag: v3.4.0 + # Generated with flatpak-builder-tools from Cargo.lock and package-lock.json + # (docs/publishing.md); the build has no network. + - cargo-sources.json + - node-sources.json + build-commands: + - mkdir -p src-tauri/.cargo + - printf '[source.crates-io]\nreplace-with = "vendored-sources"\n\n[source.vendored-sources]\ndirectory = "/run/build/modbus-tool/cargo/vendor"\n' > src-tauri/.cargo/config.toml + - npm ci --offline + - npx tauri build --no-bundle -- --offline + - install -Dm755 src-tauri/target/release/modbus-tool /app/bin/modbus-tool + - install -Dm644 packaging/flatpak/io.github.chetto1983.modbustool.desktop /app/share/applications/io.github.chetto1983.modbustool.desktop + - install -Dm644 packaging/flatpak/io.github.chetto1983.modbustool.metainfo.xml /app/share/metainfo/io.github.chetto1983.modbustool.metainfo.xml + - install -Dm644 src-tauri/icons/32x32.png /app/share/icons/hicolor/32x32/apps/io.github.chetto1983.modbustool.png + - install -Dm644 src-tauri/icons/128x128.png /app/share/icons/hicolor/128x128/apps/io.github.chetto1983.modbustool.png + - install -Dm644 src-tauri/icons/128x128@2x.png /app/share/icons/hicolor/256x256/apps/io.github.chetto1983.modbustool.png + - install -Dm644 src-tauri/icons/icon.svg /app/share/icons/hicolor/scalable/apps/io.github.chetto1983.modbustool.svg diff --git a/scripts/build-site.mjs b/scripts/build-site.mjs new file mode 100644 index 0000000..ded567d --- /dev/null +++ b/scripts/build-site.mjs @@ -0,0 +1,18 @@ +// Assembles the project page (site/) into _site for GitHub Pages: the page's own files, plus the +// app's design tokens, fonts, icon and screenshots, copied rather than duplicated in the repository. +import { cpSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"; + +const out = "_site"; +rmSync(out, { recursive: true, force: true }); +mkdirSync(out); +cpSync("site", out, { recursive: true }); +cpSync("src/assets/fonts", `${out}/fonts`, { recursive: true }); +cpSync("docs/screenshots", `${out}/screenshots`, { recursive: true }); +cpSync("src-tauri/icons/icon.svg", `${out}/icon.svg`); + +// The font faces and the theme tokens are the top of the app's stylesheet, up to its first rule. +const css = readFileSync("src/app.css", "utf8"); +const end = css.indexOf("\n* {"); +if (end < 0) throw new Error("src/app.css: the tokens no longer end before the '* {' rule"); +writeFileSync(`${out}/tokens.css`, css.slice(0, end).replaceAll("./assets/fonts/", "fonts/") + "\n"); +console.log(`Site assembled in ${out}/`); diff --git a/site/index.html b/site/index.html new file mode 100644 index 0000000..ad9d008 --- /dev/null +++ b/site/index.html @@ -0,0 +1,273 @@ + + + + + + ModbusTool: free Modbus master and slave with live dashboards + + + + + + + + + + +
+ ModbusTool + + +
+ +
+
+

Free and open source · MIT · Windows and Linux

+

Test any Modbus device,
then watch it live.

+

+ A master and a slave in one window, for TCP, UDP, RTU, ASCII and RTU over TCP. Every data type and byte order, + a frame-by-frame traffic monitor, and dashboards with trends, gauges and command panels. +

+ +
+ A dashboard reading a live slave: a smooth trend of a sine wave, a gauge, a lamp and bars +
+
+ +
+

Everything for the commissioning bench

+
+
+

Master

+

+ Several polls at once, each with its unit, function, range and interval. FC01–FC06, FC15, FC16, with + per-poll statistics. Edit a value in the grid to write it. +

+
+
+

Slave

+

+ Several unit ids with full tables, response delay, broadcast writes, and generators: sine, ramp, random + and square wave. CSV import and export. +

+
+
+

Data types

+

+ UInt16 to UInt64, Int16 to Int64, Float32, Float64, hex, binary and ASCII, in the byte orders ABCD, CDAB, + BADC and DCBA. Labels per register. +

+
+
+

Traffic monitor

+

+ Every frame, decoded into words you can read, with filters and CSV export. See exactly what went on the + wire and what came back. +

+
+
+

Dashboards

+

+ Trends with zoom, values and gauges with alarm colours, bars, lamps, buttons, switches, selectors and + setpoints. Arrange them by dragging. +

+
+
+

Scaling like SCADA tags

+

+ Map raw counts to engineering units, for example 0…27648 to 0…100 %. Setpoints are typed in their own + units and written raw. +

+
+
+ +
+ +
+

How it compares

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ModbusToolModbus Poll + SlaveModbusToolsQModMastermbpollSimply Modbus
PriceFreeUSD 129 eachFreeFreeFreeFrom USD 60
Windows · Linux✓ · ✓✓ · –✓ · ✓✓ · ✓✓ · ✓✓ · –
Master and slaveOne appTwo productsTwo appsMasterMasterSeparate products
UDP and ASCII✓✓✓––ASCII only
64-bit and doubles✓✓✓–––
Traffic monitor✓✓✓✓–Log file
Trend charts✓✓––––
Dashboards with commands✓–––––
+
+

+ – means not offered, or not stated by the project. Checked on 2026-11-06 against each project's own site; the + sources are listed in the + README. +

+
+ +
+

Download

+

The latest release is on GitHub.

+ +

+ The Windows installer is not code-signed: if SmartScreen stops it, choose More info → Run anyway. + Once installed, ModbusTool updates itself, and every update is verified with the project's key before it is + installed. +

+
+
+ + + + + diff --git a/site/site.js b/site/site.js new file mode 100644 index 0000000..b3ade7c --- /dev/null +++ b/site/site.js @@ -0,0 +1,38 @@ +// Theme switch, and direct download links to the latest release's files. Without JavaScript or +// without the GitHub API, the links still lead to the release page. + +const root = document.documentElement; + +document.querySelector(".theme")?.addEventListener("click", () => { + const next = root.dataset.theme === "light" ? "dark" : "light"; + root.dataset.theme = next; + try { + localStorage.setItem("theme", next); + } catch { + // Private windows can refuse storage: the switch still works for this visit. + } +}); + +async function latestRelease() { + const response = await fetch("https://api.github.com/repos/chetto1983/ModbusTool/releases/latest", { + headers: { Accept: "application/vnd.github+json" }, + }); + if (!response.ok) throw new Error(`GitHub API ${response.status}`); + return response.json(); +} + +latestRelease() + .then((release) => { + for (const link of document.querySelectorAll("[data-asset]")) { + const asset = release.assets.find((a) => a.name.endsWith(`.${link.dataset.asset}`)); + if (asset) link.href = asset.browser_download_url; + } + const version = document.querySelector("[data-latest-version]"); + if (version) + version.textContent = `Version ${release.tag_name.replace(/^v/, "")}, released ${release.published_at.slice(0, 10)}.`; + const label = document.querySelector("[data-latest-label]"); + if (label) label.textContent = `Download ${release.tag_name}`; + }) + .catch(() => { + // The links already point to the release page. + }); diff --git a/site/style.css b/site/style.css new file mode 100644 index 0000000..f854c65 --- /dev/null +++ b/site/style.css @@ -0,0 +1,336 @@ +/* The project page. Colours, fonts, radii and motion come only from tokens.css, which the site + build copies from the app's src/app.css: the page and the app share one palette. */ + +* { + box-sizing: border-box; +} + +body { + margin: 0; + font-size: 16px; + line-height: 1.6; +} + +a { + color: var(--color-ring); +} + +a:focus-visible, +button:focus-visible { + outline: none; + box-shadow: var(--shadow-focus); + border-radius: var(--radius-sm); +} + +img { + display: block; + max-width: 100%; + height: auto; +} + +/* ---------- top bar ---------- */ + +.bar { + position: sticky; + top: 0; + z-index: 2; + display: flex; + align-items: center; + gap: 24px; + padding: 12px clamp(16px, 4vw, 48px); + background: color-mix(in oklab, var(--color-bg) 88%, transparent); + backdrop-filter: blur(10px); + border-bottom: 1px solid var(--color-border); +} + +.brand { + display: flex; + align-items: center; + gap: 10px; + margin-right: auto; + font-family: var(--font-display); + font-size: 20px; + font-weight: 600; + color: var(--color-text); + text-decoration: none; +} + +.bar nav { + display: flex; + gap: 20px; +} + +.bar nav a { + color: var(--color-text-muted); + text-decoration: none; + font-weight: 600; + font-size: 14px; +} + +.bar nav a:hover { + color: var(--color-text); +} + +.theme { + width: 36px; + height: 36px; + border: 1px solid var(--color-border); + border-radius: var(--radius-pill); + background: var(--color-surface); + color: var(--color-text); + font-size: 18px; + cursor: pointer; +} + +/* ---------- sections ---------- */ + +main > section { + max-width: 1120px; + margin: 0 auto; + padding: clamp(48px, 8vw, 96px) clamp(16px, 4vw, 48px) 0; +} + +h1, +h2, +h3 { + font-family: var(--font-display); + font-weight: 600; + line-height: 1.15; + margin: 0; +} + +h2 { + font-size: clamp(28px, 4vw, 40px); + margin-bottom: 28px; +} + +.hero { + text-align: center; +} + +.eyebrow { + margin: 0 0 16px; + font-weight: 600; + font-size: 14px; + color: var(--color-text-faint); +} + +.hero h1 { + font-size: clamp(36px, 6.4vw, 68px); + letter-spacing: -0.01em; +} + +.lead { + max-width: 720px; + margin: 24px auto 0; + font-size: clamp(17px, 2vw, 19px); + color: var(--color-text-muted); +} + +.actions { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 12px; + margin-top: 32px; +} + +.btn { + display: inline-flex; + align-items: center; + min-height: 48px; + padding: 0 22px; + border: 1px solid var(--color-border-strong); + border-radius: var(--radius-pill); + color: var(--color-text); + font-weight: 700; + text-decoration: none; + transition: background var(--motion-fast) var(--motion-ease-out); +} + +.btn:hover { + background: var(--color-surface-2); +} + +.btn.primary { + border-color: transparent; + background: var(--color-accent); + color: var(--color-on-accent); +} + +.btn.primary:hover { + background: var(--color-accent-pressed); +} + +.shot { + margin: 48px 0 0; + border: 1px solid var(--color-border); + border-radius: var(--radius-lg); + overflow: hidden; + background: var(--color-surface); + box-shadow: var(--shadow-popover); +} + +.shot img { + width: 100%; +} + +/* ---------- features ---------- */ + +.grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); + gap: 16px; +} + +.grid article { + padding: 22px 24px; + border: 1px solid var(--color-border); + border-radius: var(--radius-md); + background: var(--color-surface); +} + +.grid h3 { + font-size: 20px; + margin-bottom: 8px; +} + +.grid p { + margin: 0; + color: var(--color-text-muted); +} + +.gallery { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); + gap: 16px; + margin-top: 32px; +} + +.gallery figure { + margin: 0; +} + +.gallery img { + border: 1px solid var(--color-border); + border-radius: var(--radius-md); +} + +.gallery figcaption { + margin-top: 8px; + font-size: 14px; + color: var(--color-text-faint); +} + +/* ---------- comparison ---------- */ + +.table { + overflow-x: auto; + border: 1px solid var(--color-border); + border-radius: var(--radius-md); + background: var(--color-surface); +} + +table { + width: 100%; + border-collapse: collapse; + font-size: 15px; +} + +th, +td { + padding: 12px 16px; + text-align: left; + border-bottom: 1px solid var(--color-border); + white-space: nowrap; +} + +tbody tr:last-child th, +tbody tr:last-child td { + border-bottom: none; +} + +thead th { + font-size: 14px; + color: var(--color-text-faint); +} + +tbody th { + font-weight: 600; +} + +td { + color: var(--color-text-muted); +} + +.us { + background: var(--color-surface-2); + color: var(--color-text); + font-weight: 700; +} + +.note { + margin: 16px 0 0; + font-size: 14px; + color: var(--color-text-faint); +} + +/* ---------- download ---------- */ + +.version { + margin: -12px 0 24px; + color: var(--color-text-muted); +} + +.platforms { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); + gap: 16px; +} + +.card { + display: grid; + gap: 4px; + padding: 22px 24px; + border: 1px solid var(--color-border); + border-radius: var(--radius-md); + background: var(--color-surface); + color: var(--color-text); + text-decoration: none; + transition: border-color var(--motion-fast) var(--motion-ease-out); +} + +.card:hover { + border-color: var(--color-ring); +} + +.card strong { + font-family: var(--font-display); + font-size: 20px; +} + +.card span { + color: var(--color-text-muted); + font-size: 14px; +} + +footer { + max-width: 1120px; + margin: 96px auto 0; + padding: 24px clamp(16px, 4vw, 48px) 48px; + border-top: 1px solid var(--color-border); + color: var(--color-text-faint); + font-size: 14px; +} + +@media (max-width: 720px) { + .bar nav { + display: none; + } +} + +@media (prefers-reduced-motion: reduce) { + * { + transition: none !important; + } +} diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 4254f9b..da140fa 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1937,7 +1937,7 @@ dependencies = [ [[package]] name = "modbus-tool" -version = "3.3.1" +version = "3.4.0" dependencies = [ "rmodbus", "serde", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 73c1246..0e29810 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "modbus-tool" -version = "3.3.1" +version = "3.4.0" description = "Modbus TCP/UDP/RTU/ASCII master and slave tool" authors = ["ModbusTool contributors"] license = "MIT" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index d8eeb1c..490502d 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "ModbusTool", - "version": "3.3.1", + "version": "3.4.0", "identifier": "io.github.chetto1983.modbustool", "build": { "beforeDevCommand": "npm run dev", @@ -26,6 +26,11 @@ "bundle": { "active": true, "targets": "all", + "publisher": "chetto1983", + "homepage": "https://github.com/chetto1983/ModbusTool", + "category": "DeveloperTool", + "shortDescription": "Modbus master and slave with live dashboards", + "longDescription": "A Modbus master and slave for TCP, UDP, RTU, ASCII and RTU over TCP, with a traffic monitor and live dashboards.", "icon": [ "icons/32x32.png", "icons/128x128.png", diff --git a/src/lib/colors.test.ts b/src/lib/colors.test.ts new file mode 100644 index 0000000..f49a759 --- /dev/null +++ b/src/lib/colors.test.ts @@ -0,0 +1,23 @@ +import { describe, expect, it } from "vitest"; +import { colourCss, colourValue, FIXED_COLOURS, isColour } from "./colors"; + +describe("variable colours", () => { + it("accepts automatic, the fixed theme colours and a custom #rrggbb, nothing else", () => { + for (const ok of [null, ...FIXED_COLOURS, "#1a2B3c"]) expect(isColour(ok), String(ok)).toBe(true); + for (const bad of ["accent", "#abc", "#12345g", "red", 3, undefined]) + expect(isColour(bad), String(bad)).toBe(false); + }); + + it("draws a fixed colour from the theme, a custom one as is, none by its position", () => { + expect(colourCss("danger", 0)).toBe("var(--color-danger)"); + expect(colourCss("#112233", 4)).toBe("#112233"); + expect(colourCss(null, 1)).toBe("var(--color-success)"); + expect(colourCss(null, FIXED_COLOURS.length)).toBe("var(--color-ring)"); + }); + + it("reads a token's value from the page for a canvas", () => { + document.documentElement.style.setProperty("--color-warning", "#fdd663"); + expect(colourValue("warning", 0)).toBe("#fdd663"); + expect(colourValue("#010203", 0)).toBe("#010203"); + }); +}); diff --git a/src/lib/colors.ts b/src/lib/colors.ts new file mode 100644 index 0000000..4813a5d --- /dev/null +++ b/src/lib/colors.ts @@ -0,0 +1,25 @@ +// Colours of dashboard variables (docs/superpowers/specs/2026-11-06-dashboards-design.md, D22): a +// fixed Aura token that follows the theme, a custom #rrggbb, or null for the automatic palette. + +/** The fixed colours, as Aura token names (--color-), in the automatic palette's order. */ +export const FIXED_COLOURS = ["ring", "success", "warning", "danger", "text-muted"] as const; +export type FixedColour = (typeof FIXED_COLOURS)[number]; + +const HEX = /^#[0-9a-f]{6}$/i; + +export const isColour = (v: unknown): boolean => + v === null || (typeof v === "string" && (HEX.test(v) || FIXED_COLOURS.includes(v as FixedColour))); + +/** A CSS colour for a variable's colour, the automatic one by its position when it has none. */ +export function colourCss(colour: string | null, index: number): string { + if (colour !== null && HEX.test(colour)) return colour; + const token = colour ?? FIXED_COLOURS[index % FIXED_COLOURS.length]; + return `var(--color-${token})`; +} + +/** The same colour as a value a canvas can draw with: a token is read from the page's theme. */ +export function colourValue(colour: string | null, index: number): string { + const css = colourCss(colour, index); + const token = /^var\((--[a-z-]+)\)$/.exec(css)?.[1]; + return token ? getComputedStyle(document.documentElement).getPropertyValue(token).trim() : css; +} diff --git a/src/lib/components/ColorField.svelte b/src/lib/components/ColorField.svelte new file mode 100644 index 0000000..9fa63db --- /dev/null +++ b/src/lib/components/ColorField.svelte @@ -0,0 +1,127 @@ + + +
+ {m.colour_label()} + + {#each FIXED_COLOURS as fixed (fixed)} + + {/each} +
+ +
+
+ + diff --git a/src/lib/components/PanelBody.svelte b/src/lib/components/PanelBody.svelte index 44decbd..24e21b7 100644 --- a/src/lib/components/PanelBody.svelte +++ b/src/lib/components/PanelBody.svelte @@ -5,6 +5,7 @@ import ValueView from "./ValueView.svelte"; import { setpointRegisters, variableLabel, writeTarget } from "../dashboardActions.svelte"; import type { Panel, SelectOption, SelectPanel, Variable } from "../dashboards"; + import { colourCss } from "../colors"; import { sameEngineering } from "../scaling"; import { master, readKey, variableScaling, variableStale, variableValue } from "../state.svelte"; @@ -66,6 +67,8 @@ const largest = Math.max(1e-9, ...values.map((v) => Math.abs(v ?? 0))); return panel.variables.map((variable, i) => ({ label: variableLabel(variable), + // One hue for every bar unless a variable has its own: colour tells them apart only on demand. + colour: colourCss(variable.colour ?? "ring", 0), value: values[i], stale: stale(variable), share: Math.abs(values[i] ?? 0) / largest, @@ -79,6 +82,7 @@ key: readKey(variable), label: variableLabel(variable), scaling: variableScaling(variable), + colour: variable.colour, }))} windowS={panel.windowS} interpolation={panel.interpolation} @@ -91,7 +95,7 @@ {#each bars as bar, i (i)}
{bar.label} - + {bar.value ?? "—"}
{:else} @@ -100,7 +104,11 @@ {:else if panel.kind === "lamp"}
- +
{:else if panel.kind === "button"}
@@ -214,9 +222,9 @@ background: var(--color-surface-3); } .lamp.on { - border-color: var(--color-success); - background: var(--color-success); - box-shadow: 0 0 0 6px color-mix(in oklab, var(--color-success) 22%, transparent); + border-color: var(--lamp); + background: var(--lamp); + box-shadow: 0 0 0 6px color-mix(in oklab, var(--lamp) 22%, transparent); } .command { min-width: 60%; @@ -311,7 +319,6 @@ .track i { display: block; height: 100%; - background: var(--color-accent); } .number { min-width: 5ch; diff --git a/src/lib/components/PanelForm.svelte b/src/lib/components/PanelForm.svelte index 94555a8..14d0bd9 100644 --- a/src/lib/components/PanelForm.svelte +++ b/src/lib/components/PanelForm.svelte @@ -54,7 +54,7 @@ {#snippet variableList(variables: Variable[])} {#each variables as _, i (i)} - + {#snippet actions()} {/snippet} @@ -126,7 +126,7 @@
{/if} {:else if panel.kind === "lamp"} - + {:else}
{/if} + {#if coloured} + + {/if}