Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

TotalTrainTool — Passive DCC Protocol Sniffer & Diagnostic Suite

TotalTrainTool is a passive, read-only Windows diagnostic and protocol-sniffing application built with Python + NiceGUI. It is tailored for model railroad layouts using a Digitrax DCS52 Zephyr Express, a Digitrax LNWI (LocoNet WiFi Interface), and an optional JMRI server.

The tool runs a local web server on your Windows PC and serves a live tabbed dashboard at http://localhost:8080 (with a clean upgrade path to view the dashboard from roaming phones/tablets over your home Wi-Fi LAN).


Project Scope & Safety Boundary

  • Approved Scope (Phase 1 & Phase 2):
    • Layer 2 — Control Bus (Digitrax LocoNet): Captures and decodes LocoNet frames via the DCS52 rear USB port or JMRI's LocoNetOverTcp server. Tracks the DCS52's 20-slot table, SLOTMAX exhaustion, STEAL/DISPATCH events, consist/MU state, speed-step modes (14/28/128), SWITCH turnout commands, and OpSw activity.
    • Layer 3 — Network & Throttle (WiThrottle / LNWI): Passively connects to the LNWI (192.168.7.1:12090 by default) or JMRI WiThrottle server to monitor connection reachability, handshake latency, server version, heartbeat interval, track power status, and 4-device LNWI capacity issues.
  • Out of Scope (Not Approved):
    • Phase 3 / Layer 1 (Raw Track Signal Capture): Any hardware build requiring an external 6N137 optocoupler and microcontroller tapping RAIL A/B or PROG A/B is excluded.
  • Strict Passive / Read-Only Mode:
    • Phase 1 and Phase 2 contain zero transmit code for LocoNet or the rails, ensuring live trains, slots, and option switches cannot be disrupted during diagnostics.

Connection Topologies & Available Data (USB vs. Wi-Fi)

You do not need to connect your Windows PC via both DCS52 USB and LNWI Wi-Fi at the same time. TotalTrainTool adapts to whichever connection mode(s) you enable in the runtime Setup dialog:

Is LNWI Wi-Fi Needed When Connected via DCS52 USB?

  • No. When your Windows PC is connected to the DCS52's rear USB port (or connected to JMRI's LocoNetOverTcp server), the app already receives the complete Layer 2 (LocoNet) stream. Because the LNWI translates every mobile throttle command onto LocoNet, all mobile throttle speed, direction, function, and turnout actions are captured in full over Layer 2 without joining the LNWI Wi-Fi.
  • (Note: If JMRI is running on the same PC and occupying the DCS52 USB COM port, close JMRI for Direct USB mode or use JMRI LocoNetOverTcp mode to share the stream without a COM port conflict.)

What Extra Data Is Available With Both USB and Wi-Fi Connected?

Enabling the Layer 3 Passive WiThrottle Monitor alongside Layer 2 (DCS52 USB) adds network- and socket-level telemetry that USB LocoNet capture alone cannot see:

  • Layer 3 Socket & Session Metrics: Connection reachability to the LNWI (192.168.7.1:12090 by default) or JMRI WiThrottle server, TCP handshake latency (ms), server software/protocol version, and heartbeat interval.
  • WiThrottle-Level Power & Protocol State: Track power state (ON / OFF / Unknown) and server protocol messages as reported at the WiThrottle TCP layer.
  • Cross-Layer & Capacity Diagnostics: Side-by-side Layer 3 WiThrottle events and Layer 2 LocoNet frames to help diagnose Wi-Fi/bridge behavior and detect when an LNWI rejects connections at its 4-device limit.

Connection Topology Comparison

Setup Scenario DCS52 USB Needed? LNWI Wi-Fi Needed? Data & Telemetry Captured
1. Direct DCS52 USB Only (Recommended starting mode) Yes (PC to DCS52 rear USB, JMRI closed) No Full Layer 2 LocoNet traffic: all 20 DCS52 slots, SLOTMAX/STEAL/DISPATCH, MU consists, SWITCH turnouts, OpSw changes, and all mobile throttle commands translated onto LocoNet by the LNWI
2. JMRI LocoNetOverTcp Only No (JMRI holds the USB port) No Full Layer 2 LocoNet traffic relayed over TCP port 1234 concurrently with JMRI, plus optional Layer 3 telemetry if pointing WiThrottle at JMRI
3. Direct USB + LNWI Wi-Fi Yes Yes (PC joined to Dtx1-LnServer_XXXX-7) Full Layer 2 LocoNet traffic plus Layer 3 LNWI reachability, TCP handshake latency, server version, heartbeat interval, WiThrottle track power state, and 4-device limit checks
4. Offline Simulator No No Built-in synthetic LocoNet frames for verifying the UI, filters, and exports offline

Operational Notes for LNWI Wi-Fi

  • LNWI 4-Device Limit: Each LNWI supports up to 4 concurrent Wi-Fi devices. Connecting your Windows PC to the LNWI Wi-Fi uses 1 of those 4 slots, leaving 3 slots for mobile throttles.
  • LNWI Traffic Visibility & Routing: Joining the LNWI Wi-Fi creates a dedicated point-to-point link to 192.168.7.1:12090; it does not mirror raw TCP packets from other phones and does not route Internet/WAN traffic. If using a single Wi-Fi adapter on Windows, uncheck Connect automatically on your home Wi-Fi profile during testing so Windows does not drop the LNWI SSID.

Key Features Implemented

  • Tabbed Web Interface (NiceGUI):
    • Persistent Status Bar: Displays the locked PASSIVE / READ-ONLY badge, Layer 2 connection status, Track Power state, live DCS52 slot gauge (X / 20, turning red at 18+), and Start / Stop / Setup controls.
    • Tab 1 — Live Stream: Unified chronological log of Layer 2 (LocoNet) and Layer 3 (WiThrottle) events with live address/text filtering, idle/ACK noise suppression, pause/resume, and one-click CSV and JSON session export.
    • Tab 2 — DCS52 Slots (20): Real-time 20-row slot table tracking locomotive address, status (Free, Common, Idle, In-Use), MU/Consist role, speed-step mode (14, 28, 128), direction, speed, and functions (F0–F4).
    • Tab 3 — WiThrottle & LNWI: Live connection cards for status, protocol version, handshake latency, and heartbeat interval.
    • Tab 4 — Switch & OpSw Log: Dedicated history of turnout (SWITCH) and Option Switch (OpSw) commands.
  • Runtime Setup Menu (sniffer_config.json):
    • Launches with zero hard-coded layout details.
    • Automatically scans available Windows COM ports.
    • Lets the user switch at runtime between Direct DCS52 USB (COM Port), JMRI LocoNetOverTcp (TCP Socket), and Offline Simulator (Test Mode), and optionally enable the Layer 3 Passive WiThrottle Monitor.

Project Directory Contents

File Purpose
app.py Main NiceGUI web server, tabbed UI, runtime Setup dialog, and CSV/JSON log exporter
config.py Loads and saves runtime user settings to sniffer_config.json
loconet_decoder.py Passive LocoNet binary frame parser, XOR checksum validator, DCS52 20-slot state tracker, and Switch/OpSw decoder
transports.py Selectable Layer 2 readers (Direct USB COM, JMRI LocoNetOverTcp, Offline Simulator) and Layer 3 passive WiThrottle monitor
requirements.txt Python package dependencies (nicegui, pyserial)
Run_TotalTrainTool.bat One-click Windows launcher that sets up a local virtual environment, installs dependencies, and starts app.py
doc/DCC_Architecture_Summary_Figure.jpg Visual diagram of the 3-layer DCC/LocoNet/WiThrottle architecture and diagnostic tap points
doc/TotalTrainTool End-User Testing & Data Collection Guide.pdf End-user testing, setup, and log collection guide

Additional Software Required & Windows Installation Commands

1. Operating System & Browser

  • Windows 10 or Windows 11 (64-bit)
  • Any modern web browser (Microsoft Edge, Google Chrome, or Firefox)
  • Internet connection is required only once during initial setup to install Python and its packages (not needed if running the standalone TotalTrainTool.exe release). After setup, the tool runs completely offline on localhost.

2. Install Python 3.10+ (Required When Running From Source)

TotalTrainTool requires Python 3.10 or newer (which includes pip and venv).

Option A — Install via Windows Package Manager (winget) (Recommended): Open PowerShell or Command Prompt and run:

winget install -e --id Python.Python.3.12

Option B — Direct Installer: Download the 64-bit Windows installer from python.org/downloads and ensure "Add python.exe to PATH" is checked during installation.

3. Install Python Supporting Libraries

The required Python libraries listed in requirements.txt are:

  • nicegui>=2.0.0 (Local FastAPI/WebSocket web UI framework)
  • pyserial>=3.5 (Windows USB COM port serial reader and port scanner)

Automatic Install (Easiest): Double-click Run_TotalTrainTool.bat. On first run, it automatically creates a local virtual environment at %LOCALAPPDATA%\TotalTrainTool\venv (keeping cloud-synced folders fast by not syncing venv files) and installs requirements.txt.

Manual Install via PowerShell: If you prefer to set up the environment manually, run the following commands in PowerShell:

python -m venv "$env:LOCALAPPDATA\TotalTrainTool\venv"
& "$env:LOCALAPPDATA\TotalTrainTool\venv\Scripts\Activate.ps1"
python -m pip install --upgrade pip
pip install -r requirements.txt
python app.py

4. DCS52 USB Serial Driver Check (Built into Windows 10/11)

When you connect your Windows PC to the rear USB port of the Digitrax DCS52, Windows 10/11 automatically assigns a standard USB Serial COM port. To check which COM port was assigned, run in PowerShell:

Get-PnpDevice -Class Ports -Status OK | Format-Table FriendlyName, Status

(You can also check Device Manager → Ports (COM & LPT).)

5. Optional: JMRI & Java (Only if Using LocoNetOverTcp Mode)

If you want to run JMRI and TotalTrainTool at the same time on the same Windows PC, Windows will not allow both programs to open the DCS52 USB COM port simultaneously. Instead:

  1. Open JMRI (which requires Java 11 or 17).
  2. In JMRI's top menu, select LocoNet → Start LocoNetOverTcp Server (default TCP port 1234).
  3. In TotalTrainTool's Setup dialog, select JMRI LocoNetOverTcp (TCP Socket) pointing to 127.0.0.1:1234.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages