Add direct ACC shared-memory RPM ingestion to telemetry bridge#1
Add direct ACC shared-memory RPM ingestion to telemetry bridge#1
Conversation
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/1c5e11a3-1121-4ded-890a-d44821be9fe5 Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/1c5e11a3-1121-4ded-890a-d44821be9fe5 Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/1c5e11a3-1121-4ded-890a-d44821be9fe5 Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/1c5e11a3-1121-4ded-890a-d44821be9fe5 Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
|
Can you please make that in the ui the vars are changeable you made? @copilot |
There was a problem hiding this comment.
Pull request overview
This PR adds a universal UDP JSON telemetry ingestion path to drive existing wheel/dash RPM indicator telemetry commands, enabling external game/tools to forward normalized RPM data into Boxflat.
Changes:
- Introduces
TelemetryBridgeUDP listener (localhost, configurable port) that parses several JSON shapes and normalizes to a 10‑LED mask. - Wires the bridge into the app lifecycle (startup + shutdown) so telemetry is available while the app runs.
- Updates README with concrete telemetry bridge usage and payload formats.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
boxflat/telemetry_bridge.py |
New UDP telemetry bridge implementation that parses JSON, normalizes RPM to a 10‑bit mask, and forwards to existing wheel/dash telemetry commands. |
boxflat/app.py |
Initializes the telemetry bridge during app startup and triggers shutdown on application shutdown. |
README.md |
Documents the telemetry bridge port/configuration and accepted JSON payload shapes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def shutdown(self) -> None: | ||
| self._shutdown.set() | ||
|
|
There was a problem hiding this comment.
shutdown() only sets the event; the worker thread may keep running for up to the socket timeout and can still process/send one more telemetry packet during app shutdown. Consider having shutdown() actively unblock the socket and join() the thread (or otherwise guarantee it has stopped) so device commands aren't sent after shutdown starts.
boxflat/telemetry_bridge.py
Outdated
| direct_mask = self._first_number(data, "rpm_led_mask", "rpmMask", "rpm-mask", "led_mask") | ||
| if direct_mask is not None: | ||
| return max(0, min(1023, int(direct_mask))) |
There was a problem hiding this comment.
int(direct_mask) can raise (e.g., if the sender provides Infinity/NaN, which Python's json can parse), crashing the telemetry thread. Add validation (e.g., math.isfinite) and/or wrap the conversion to ensure malformed inputs are ignored rather than terminating the bridge.
boxflat/telemetry_bridge.py
Outdated
| if rpm is None or max_rpm is None or max_rpm <= 0: | ||
| return None | ||
| ratio = rpm / max_rpm | ||
| elif ratio > 1: |
There was a problem hiding this comment.
rpm_ratio values < 0 are currently clamped to 0 (via max(0, ...)) rather than rejected, but the documented/input contract here is 0.0–1.0 (and rpm_percent rejects out-of-range). Add a < 0 check for rpm_ratio (and optionally for derived rpm/max_rpm) so invalid negative ratios are handled consistently.
| elif ratio > 1: | |
| elif ratio < 0 or ratio > 1: |
boxflat/telemetry_bridge.py
Outdated
| ratio = max(0, min(1, ratio)) | ||
| lit_leds = int(round(ratio * 10)) | ||
| return (1 << lit_leds) - 1 if lit_leds > 0 else 0 |
There was a problem hiding this comment.
ratio can become non-finite (e.g., NaN/Infinity from JSON or division) and then round(ratio * 10) will raise, killing the worker thread. Before rounding, ensure ratio is finite (e.g., math.isfinite(ratio)), and ignore packets with invalid numeric values.
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/990b6761-2069-486e-8e15-75594adf62af Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Implemented in commit |
|
@copilot How can I build the application so I can test it. |
Quickest way to test from source:
If you want a system-style install instead: If you want, I can also add a short “Build/Test locally” section to README. |
|
@copilot When I go into Asseto Corsa Competizione for example MY RPM indication is just blincing and not showing the rpm. Can you please implement some login features so yYou can fix the issue |
…g logging Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/53b64d6c-9bbf-48a3-b975-9e19b7b5719f Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/53b64d6c-9bbf-48a3-b975-9e19b7b5719f Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/53b64d6c-9bbf-48a3-b975-9e19b7b5719f Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Implemented in To diagnose ACC input live, run Boxflat with: Then watch terminal logs for lines like No UI changes were made in this fix, so there is no new UI screenshot. |
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/e9cbd4a0-1f2d-4b62-a50d-77a3c8452217 Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/e9cbd4a0-1f2d-4b62-a50d-77a3c8452217 Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/b3d48a0e-561d-4f2f-b15d-efdbd9ca3bf5 Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/4264d549-93b0-4fb3-9c3c-6a450ca5d85f Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/6a1c89eb-7ec8-4c9c-96be-4e80c7880975 Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/6a1c89eb-7ec8-4c9c-96be-4e80c7880975 Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
Agent-Logs-Url: https://github.com/SiFuMax09/boxflat/sessions/6a1c89eb-7ec8-4c9c-96be-4e80c7880975 Co-authored-by: SiFuMax09 <131544883+SiFuMax09@users.noreply.github.com>
ACC users expected wheel RPM telemetry without running a separate adapter. Boxflat previously relied on UDP JSON input only, so ACC data had to be translated externally before RPM LEDs could update.
Telemetry bridge: dual input path (ACC shared memory + existing UDP JSON)
boxflat/telemetry_bridge.pythat reads:rpmfromacpmf_physics(offset20)max_rpmfromacpmf_static(offset416)rpm/max_rpminto the existing 10-bit LED mask and forwards through the current wheel/dash telemetry commands.Source coordination and robustness
Docs update for ACC behavior
Focused parsing coverage
tests/test_telemetry_bridge_acc.pyto verify ACC RPM/max-RPM extraction from the configured offsets.Example of the new ACC read path:
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.