The bridge reads the COM port and streams SSE to the frontend; it never
talks to Django. backend_client.py (a Django API client) and config.py
(which held BACKEND_URL / API_ENDPOINT) were imported by nothing - app.py
calls load_dotenv() and reads os.getenv directly, and the PyInstaller spec
builds from app.py alone.
Their presence implied a coupling that does not exist, and the stale
BACKEND_URL=8000 in .env read as a misconfiguration rather than an inert
value.
Also drops the matching backend settings from .env.example, the now
unnecessary 'requests' hidden import from the spec, and the two files from
the SETUP.md tree. requests and urllib3 remain in requirements.txt - no
bridge module uses them now, but pruning dependencies is a build concern
left for a separate change.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The bridge becomes pure transport: it opens the port, writes a poll
string it is given at runtime, and streams raw lines. Protocol
definitions live in Django and parsing happens in the browser, so a new
scale type never means a new binary on the station PCs. The poll loop
stays in the bridge because a browser cannot be the heartbeat - hidden
tabs get throttled and a closed tab would stop the scale.
Every payload now carries a hex field. Toledo Continuous sends STX and
bit-packed status, which UTF-8 decoding silently corrupts. Fixed-column
protocols need the opposite care: a space can mean balanced, so the
trailing whitespace must survive.
Parsers for the simulator, fixed-column, Toledo Continuous and SICS
return an explicit error rather than a guess on a frame that does not
match, since a silently wrong weight on a weighbridge is worse than no
weight. Toledo and SICS are written from documented structure and have
not been validated against real hardware.
The admin monitor shows the raw stream as text and hex, sends one-off
probe commands, and builds fixed-column protocols against captured
lines. Spaces render as middots because in some protocols a space is
the stability flag.
The test writer now simulates a weighing cycle - idle, ramp, balanced,
drop - alternating empty and loaded trucks, quantised to the 20kg and
50kg divisions real truck scales use.
Bridge logging rotates and per-reading lines drop to DEBUG; the old
config had grown two log files totalling 368MB.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>