You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.7 KiB
Markdown

# 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:**
```bash
pip install -r requirements.txt
```
2. **Configure environment:**
```bash
copy .env.example .env
# Edit .env with your settings
```
3. **Run the application:**
```bash
python app.py
```
## Building as EXE
To create a standalone Windows executable:
```bash
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