Add serial configuration UI and LiDAR network configuration design#290
Add serial configuration UI and LiDAR network configuration design#290
Conversation
🤖 Version Bump AdvisoryWarnings
📖 See CHANGELOG.md for detailed guidelines. This is an automated advisory. Review the detected changes and update versions accordingly. |
There was a problem hiding this comment.
Pull request overview
This PR implements a comprehensive serial configuration UI and API for velocity.report, enabling database-driven serial port management with hot-reload capability. The changes introduce a new configuration layer that allows users to manage multiple serial port configurations for radar sensors through a web interface, test connections, and reload configurations without restarting the server.
Changes:
- Added complete serial configuration UI in Svelte with CRUD operations, connection testing, and sensor model selection
- Implemented SerialPortManager with hot-reload support and persistent event fanout across mux swaps
- Added database schema and migration for radar_serial_config table with sensor model constraints
- Created API endpoints for serial configuration, device discovery, testing, and reloading
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| web/src/routes/(constrained)/settings/serial/+page.svelte | New Svelte page for serial configuration UI with create/edit/delete/test functionality |
| web/src/routes/(constrained)/settings/+page.svelte | Added navigation link to serial configuration page using $app/paths resolve() |
| web/src/lib/api.ts | Added TypeScript types and API client functions for serial configuration endpoints |
| internal/serialmux/options.go | New PortOptions type with Normalise(), Equal(), and SerialMode() methods (British English) |
| internal/db/serial_config.go | Database CRUD operations for serial configurations |
| internal/db/serial_config_test.go | Comprehensive test coverage for DB layer including constraints |
| internal/db/schema.sql | Added radar_serial_config table with triggers and indexes |
| internal/db/migrations/000029_create_radar_serial_config.up.sql | Migration creating serial config table with default HAT configuration |
| internal/db/migrations/000029_create_radar_serial_config.down.sql | Rollback migration for serial config table |
| internal/api/sensor_models.go | Sensor model registry with OPS243-A and OPS243-C definitions |
| internal/api/serial_config.go | HTTP handlers for serial config CRUD operations with validation |
| internal/api/serial_config_test.go | API endpoint tests covering create/read/update/delete operations |
| internal/api/serial_testing.go | Serial port testing endpoint with auto-baud detection and device discovery |
| internal/api/serial_reload.go | SerialPortManager with hot-reload, event fanout, and thread-safe mux swapping |
| internal/api/serial_reload_test.go | Tests for SerialPortManager subscription persistence and delegation |
| internal/api/server.go | Registered serial API routes and added SetSerialManager() method |
| .gitignore | Added web/build/ to ignore list |
internal/db/migrations/000029_create_radar_serial_config.up.sql
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…s, reload manager, and tests Co-authored-by: ddol <445312+ddol@users.noreply.github.com>
…th CRUD and test dialogs Co-authored-by: ddol <445312+ddol@users.noreply.github.com>
Co-authored-by: ddol <445312+ddol@users.noreply.github.com>
- Refactor testSerialPort to use serialmux.PortOptions.Normalise/SerialMode - Add active-port warning when testing a port in use by SerialPortManager - Relax CHECK constraint to LIKE 'ops243-%' for future extensibility - Add tests for serial config, HINT sweep, and sweep explanation API functions Co-authored-by: ddol <445312+ddol@users.noreply.github.com>
…ve 90%+ coverage Files covered: - serialmux/options.go: 0% → 100% - db/serial_config.go: 65.62% → 93.2% - api/serial_config.go: 40.11% → 92.3% - api/serial_reload.go: 34.32% → 96.2% - api/server.go: 21.42% → 90.2% (serial portions) Co-authored-by: ddol <445312+ddol@users.noreply.github.com>
c22c77d to
e216309
Compare
b2d09fc to
e216309
Compare
Replaces the stale
copilot/add-serial-configuration-uibranch with a clean reimplementation against currentmain. Adds DB-driven serial port configuration with hot-reload, a settings UI, and a design document for extending the same pattern to LiDAR network interfaces.Serial port configuration backend
internal/db/serial_config.go): CRUD forradar_serial_configtable with migration 000029. Schema usesLIKE 'ops243-%'CHECK constraint for sensor model extensibility.serialmux.PortOptions(internal/serialmux/options.go): Typed serial parameters withNormalise(),Equal(),SerialMode(). Validates baud rates 110–256000. Defaults: 19200/8N1.SerialPortManager(internal/api/serial_reload.go): Hot-reload wrapper implementingSerialMuxInterface. Maintains persistent event fanout across reloads viaRWMutex-guarded delegation. BackgroundMonitor()polls DB for config changes.internal/api/serial_config.go,serial_testing.go): REST endpoints at/api/serial/{configs,models,test,devices,reload}. Test endpoint usesPortOptions.Normalise()/SerialMode()and warns when probing an active port.internal/api/sensor_models.go): Static catalogue of supported radar models with default serial parameters.Web frontend
web/src/routes/(constrained)/settings/serial/+page.svelte): Config CRUD with add/edit dialogs, port test with live feedback, device enumeration.web/src/lib/api.ts): Typed functions for all serial and HINT sweep endpoints.Test coverage
serialmux/options_test.go: 27 tests covering Normalise/Equal/SerialMode — 0% → 100%db/serial_config_test.go: Error paths, not-found, disabled flag — 65% → 93%api/serial_config_test.go: Method validation, field validation, DB errors — 40% → 92%api/serial_reload_test.go: ReloadConfig paths, Monitor retry/cancel, event fanout — 34% → 96%api/server.goserial routes: SetSerialManager, currentSerialMux fallback — 21% → 90%web/src/lib/api.test.ts: 29 new tests for serial + HINT endpoints — functions 81% → 100%LiDAR network configuration design
docs/lidar/architecture/lidar-network-configuration.md: Extends the SerialPortManager hot-reload pattern to LiDAR UDP listener binding. Covers interface enumeration, gateway/address discovery, Hesai traffic probing (ports 2368–2370), and live rebind without process restart. DefinesLiDARNetworkManager, DB schema (lidar_network_config), API surface, and settings UI wireframe.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.