Files
scalesApp/serial_bridge
gitea edfe2f1bfe Remove the serial bridge's unused Django client
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>
2026-09-18 19:49:14 +03:00
..
2026-02-21 19:53:04 +02:00

Serial Bridge - COM Port Reader

This is the serial port reading application that runs as a system tray service.

Features

  • ✅ Reads data from COM ports
  • ✅ Runs in system tray (no console window)
  • ✅ Automatically posts data to Django backend
  • ✅ Retry logic for failed posts
  • ✅ Backend health checks
  • ✅ Configurable via environment variables
  • ✅ Can be packaged as a Windows .exe

Setup

  1. Install Python dependencies:

    pip install -r requirements.txt
    
  2. Configure environment:

    copy .env.example .env
    # Edit .env with your settings
    
  3. Run the application:

    python app.py
    

Building as EXE

To create a standalone Windows executable:

pip install pyinstaller
pyinstaller serial_bridge.spec

The executable will be created in the dist\ScalesApp\ folder.

Configuration

Edit .env to configure:

  • COM_PORT: COM port to read from (default: COM1)
  • BAUD_RATE: Serial port baud rate (default: 9600)
  • BACKEND_URL: Django backend URL (default: http://localhost:8000)
  • AUTO_CONNECT: Automatically connect on startup (default: True)
  • DEBUG: Enable debug logging (default: False)

Architecture

COM Port → Serial Reader → Backend Client → Django API
                             ↓
                         System Tray Icon

Logging

Logs are written to serial_bridge.log and console output.

Troubleshooting

  • COM port not found: Check COM_PORT setting and device connection
  • Cannot connect to backend: Verify Django server is running on BACKEND_URL
  • Data not posting: Check logs in serial_bridge.log
  • Tray icon not appearing: Run as administrator, check Windows settings