How morgendagen/riden-dongle works
Purpose and deployment
Riden Dongle is ESP-12F/ESP8266 firmware replacing the stock Riden WiFi-module software. It bridges a Riden DC power supply’s UART Modbus RTU interface to LAN protocols: Modbus TCP, SCPI raw socket/VXI-11, and an embedded control/configuration web UI. PlatformIO builds the device firmware; the application entry point is src/main.cpp, with target configuration in platformio.ini.
Bootstrap and orchestration
src/main.cpp owns firmware lifecycle: hardware/network initialization, service startup, and periodic device-facing work. It composes the protocol, configuration, HTTP, and discovery/time capabilities rather than exposing a separate host application. Public component contracts are under include/, including include/riden_config/riden_config.h and include/riden_modbus/riden_modbus.h.
Device bus and canonical PSU access
src/riden_modbus/riden_modbus.cpp implements the Modbus RTU client that communicates with the physical Riden PSU over UART. Register definitions and device-model semantics are centralized in include/riden_modbus/riden_modbus_registers.h. This is the core hardware boundary: all remote protocols ultimately read/write PSU state through this layer, constrained by UART baud rate, Modbus address, and the PSU firmware’s register behavior.
Modbus TCP bridge
src/riden_modbus_bridge/riden_modbus_bridge.cpp translates inbound Modbus TCP requests into the local RTU/register operations. Its interface is include/riden_modbus_bridge/riden_modbus_bridge.h. This path preserves standard Modbus client compatibility while isolating network request handling from serial-device access.
SCPI and instrument transports
src/riden_scpi/riden_scpi.cpp maps SCPI commands and queries to PSU operations, with its public API in include/riden_scpi/riden_scpi.h; supported command surface is documented in SCPI_COMMANDS.md. src/scpi_bridge/scpi_bridge.h adapts transport input to that SCPI engine. Raw SCPI socket service and VXI-11 are mutually constrained at runtime: VXI-11 provides synchronous RPC-style instrument access, while raw socket supplies TCP port-5025 VISA compatibility.
VXI-11 RPC server
src/vxi11_server/vxi_server.cpp implements the VXI-11 instrument server, with RPC framing in src/vxi11_server/rpc_packets.cpp and port-mapper/binder behavior in src/vxi11_server/rpc_bind_server.cpp. This boundary exposes SCPI to VISA clients using TCPIP::<host>::INSTR, and participates in mDNS-based LAN discovery. The subsystem’s local design notes are in src/vxi11_server/README.md.
HTTP UI, configuration, and operations
src/riden_http_server/riden_http_server.cpp serves the embedded web interface for PSU status/control, graphs, device configuration, reboot actions, and OTA update flow. Static browser content is compiled into src/riden_http_server/http_static.h; source/mock UI artifacts live in src/riden_http_server/html_content/. HTTP routes invoke the same PSU/configuration services as the machine protocols, making the UI another client boundary rather than a separate control plane.
Persistent configuration and external services
src/riden_config/riden_config.cpp manages dongle settings such as timezone and UART configuration; timezone data is in src/riden_config/timezones.h. Runtime infrastructure includes ESP Wi-Fi provisioning via WiFiManager, IPv4 LAN connectivity, mDNS service advertising, NTP synchronization against pool.ntp.org, and OTA firmware delivery through the HTTP interface. The resulting clock/time configuration is propagated to the PSU through the Modbus access layer.
Main entry points: main.cpp Firmware lifecycle · riden_modbus.cpp Modbus RTU client · riden_http_server.cpp HTTP control server · vxi_server.cpp VXI-11 server
Components 17
Firmware core
- PlatformIO build · Build target configuration.
platformio.ini - Firmware lifecycle · Initializes hardware/network services and runs periodic work.
src/main.cpp - Persistent configuration · Stores timezone and UART settings.
src/riden_config/riden_config.cpp
PSU access
- Modbus RTU client · Canonical read/write access to the Riden PSU.
src/riden_modbus/riden_modbus.cpp - PSU register model · Centralizes register and device-model semantics.
include/riden_modbus/riden_modbus_registers.h - Riden DC power supply
LAN protocols
- Modbus TCP bridge · Translates Modbus TCP requests into local register operations.
src/riden_modbus_bridge/riden_modbus_bridge.cpp - Modbus TCP clients
- SCPI command engine · Maps SCPI commands and queries to PSU operations.
src/riden_scpi/riden_scpi.cpp - Raw SCPI socket · Provides VISA-compatible raw SCPI access.
src/scpi_bridge/scpi_bridge.h - VXI-11 server · Exposes synchronous SCPI instrument access for VISA clients.
src/vxi11_server/vxi_server.cpp - VXI-11 RPC framing · Handles RPC packets and port-mapper binding.
src/vxi11_server/rpc_packets.cpp - VISA clients
Web and infrastructure
- HTTP control server · Serves status, control, configuration, reboot, and OTA routes.
src/riden_http_server/riden_http_server.cpp - Embedded web UI
src/riden_http_server/http_static.h - Browser clients
- Wi-Fi, mDNS and NTP · Provides provisioning, LAN discovery, and clock synchronization.
Connections 24
- PlatformIO build → Firmware lifecycle: builds
- Firmware lifecycle → Persistent configuration: initializes
- Firmware lifecycle → Modbus RTU client: runs
- Firmware lifecycle → Modbus TCP bridge: starts
- Firmware lifecycle → Raw SCPI socket: starts
- Firmware lifecycle → VXI-11 server: starts
- Firmware lifecycle → HTTP control server: starts
- Firmware lifecycle → Wi-Fi, mDNS and NTP: initializes
- Persistent configuration → Modbus RTU client: applies UART/time settings
- Modbus RTU client → PSU register model: uses
- Modbus RTU client → Riden DC power supply: Modbus RTU over UART
- Modbus TCP clients → Modbus TCP bridge: Modbus TCP
- Modbus TCP bridge → Modbus RTU client: register operations
- Raw SCPI socket → SCPI command engine: SCPI commands
- VXI-11 server → VXI-11 RPC framing: uses
- VXI-11 RPC framing → VISA clients: VXI-11 RPC
- VXI-11 server → SCPI command engine: SCPI commands
- SCPI command engine → Modbus RTU client: PSU operations
- Browser clients → HTTP control server: HTTP
- HTTP control server → Embedded web UI: serves
- HTTP control server → Persistent configuration: configures
- HTTP control server → Modbus RTU client: status and control
- Wi-Fi, mDNS and NTP → VXI-11 server: mDNS discovery
- Wi-Fi, mDNS and NTP → Modbus RTU client: propagates synchronized time