5a8527e96e975780ee3970c4fc1c865edeca1d2d
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>
ScalesApp - Multi-Component Application
A distributed application consisting of three main components:
Architecture
1. Frontend (React)
- Location:
/frontend - Description: React web application that displays real-time data from the serial port
- Communicates with: Django backend via REST API
- Port: 3000 (default)
2. Backend (Django)
- Location:
/backend - Description: Django REST API server for storing and retrieving serial data
- Database: SQLite (configurable)
- Port: 8000 (default)
3. Serial Bridge (Python)
- Location:
/serial_bridge - Description: Python application that reads data from COM ports
- Features: System tray integration, runs as EXE (via PyInstaller)
- Communicates with: Django backend via REST API
- Data Flow: COM Port → Serial Bridge → Django Backend → React Frontend
Installation & Setup
Prerequisites
- Node.js 16+ (for React)
- Python 3.8+ (for Django and Serial Bridge)
- pip or conda for Python packages
Quick Start
-
Backend Setup
cd backend python -m venv venv venv\Scripts\activate pip install -r requirements.txt python manage.py migrate python manage.py runserver -
Frontend Setup
cd frontend npm install npm start -
Serial Bridge Setup
cd serial_bridge python -m venv venv venv\Scripts\activate pip install -r requirements.txt python app.py
Data Flow
COM Port
↓
Serial Bridge (Python)
↓
Django Backend REST API
↓
React Frontend
Configuration
Each component has its own configuration file:
- Frontend:
.env - Backend:
settings.pyand.env - Serial Bridge:
config.pyand.env
Development Tips
- Keep all three services running during development
- Use
CORSheaders properly in Django for frontend requests - Serial Bridge should continuously read COM data and POST to backend
- Frontend should poll/subscribe to backend for updates
Description
VehicleScales app with Django and React. It has a python service reading from comport and forwarding data to frontend via sse
Languages
JavaScript
62.1%
Python
23.8%
CSS
13.8%
Dockerfile
0.1%