Files
trx-rs/CLAUDE.md
T
Claude c8f33b8939 [refactor](trx-rs): remove shared-library plugin system
Drop the plugin loading infrastructure (libloading-based dynamic .so/.dylib/.dll
loading) from both trx-server and trx-client. The feature was unused and posed an
unnecessary security risk by executing arbitrary native code from disk.

Removed:
- src/trx-app/src/plugins.rs (plugin discovery, validation, FFI registration)
- examples/trx-plugin-example/ (cdylib example plugin)
- libloading dependency from trx-app
- load_backend_plugins / load_frontend_plugins calls from server and client
- Plugin documentation from README.md and CLAUDE.md

https://claude.ai/code/session_01DTEUpz3XPUeWmz74NeaFgb
Signed-off-by: Claude <noreply@anthropic.com>
2026-03-26 12:44:56 +01:00

98 lines
3.5 KiB
Markdown

# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Commands
```bash
# Build
cargo build --release
# Run tests
cargo test
# Lint
cargo clippy
# Run a single test (by name pattern)
cargo test <test_name>
# Run tests for a specific crate
cargo test -p trx-core
# Generate example config
./target/release/trx-server --print-config > trx-server.toml
./target/release/trx-client --print-config > trx-client.toml
# Run server
./target/release/trx-server --config trx-server.toml
# or via CLI args:
./target/release/trx-server -r ft817 "/dev/ttyUSB0 9600"
# Run client
./target/release/trx-client --config trx-client.toml
```
## Crate Layout
This is a Cargo workspace. All crates live under `src/`:
```
src/
trx-core/ # Core types, traits, state machine, controller
trx-protocol/ # Client↔server protocol conversion, auth, codec
trx-app/ # Shared application helpers (config, plugins, logging)
trx-server/ # Server binary (rig_task, audio, APRS-IS, PSKReporter)
trx-backend/ # Backend abstraction trait + factory
trx-backend-ft817/ # Yaesu FT-817 CAT implementation
trx-backend-ft450d/ # Yaesu FT-450D CAT implementation
trx-client/ # Client binary (connects to server, runs frontends)
trx-frontend/ # Frontend trait (FrontendSpawner)
trx-frontend-http/ # Web UI with REST API, SSE, and auth
trx-frontend-http-json/ # JSON-over-TCP control frontend
trx-frontend-rigctl/ # Hamlib-compatible rigctl TCP interface
decoders/
trx-aprs/ # APRS packet decoder
trx-cw/ # CW (Morse) decoder
trx-ftx/ # Pure Rust FTx decoder (FT8/FT4/FT2)
trx-wspr/ # WSPR decoder
trx-decode-log/ # Shared decoder logging (JSON Lines, date-rotated files)
```
## Architecture
The project is split into a **server** (connects to the radio hardware) and a **client** (exposes user-facing frontends). They communicate over a JSON TCP connection (default port 4530). Audio streams over a separate TCP connection (default port 4531) using Opus encoding.
### Data flow
```
Radio hardware
↕ serial/TCP
trx-server (rig_task.rs)
↕ trx-protocol JSON-TCP (port 4530)
trx-client (remote_client.rs)
↕ internal channels
Frontends: HTTP (8080), rigctl (4532), http-json (ephemeral)
```
### trx-core controller
The rig controller (`src/trx-core/src/rig/controller/`) is the central state management component:
- **`machine.rs`** — `RigMachineState` enum with states: `Disconnected`, `Connecting`, `Initializing`, `PoweredOff`, `Ready`, `Transmitting`, `Error`
- **`handlers.rs`** — `RigCommandHandler` trait; commands: `SetFreq`, `SetMode`, `SetPtt`, `PowerOn/Off`, `ToggleVfo`, `Lock/Unlock`, `GetSnapshot`, etc.
- **`events.rs`** — `RigListener` trait and `RigEventEmitter` for broadcasting frequency/mode/PTT/state/meter/lock/power changes
- **`policies.rs`** — `RetryPolicy` (`ExponentialBackoff`, `FixedDelay`, `NoRetry`) and `PollingPolicy` (`AdaptivePolling`, `FixedPolling`, `NoPolling`)
### Decoders
Signal decoders run as background tasks in `trx-server`, consuming decoded audio. `trx-ftx` provides the FT8/FT4/FT2 decoder in pure Rust. Decoded frames can be forwarded to PSKReporter and APRS-IS (IGate) uplinks, or logged via `trx-decode-log`.
## Commit Format
```
[<type>](<crate>): <description>
```
Types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`. Use `(trx-rs)` for repo-wide changes. Sign commits with `git commit -s`. Write isolated commits per crate.