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.
kikimor 33b49e317d added docker-compose for linux fixed 3 comport writer 2 weeks ago
..
.env.example barebone app with django and react, sse, jwt token, comport reader, test comport writer, requires com0com, users with groups, sample table vehicles, tokens for access and refresh 2 months ago
README.md barebone app with django and react, sse, jwt token, comport reader, test comport writer, requires com0com, users with groups, sample table vehicles, tokens for access and refresh 2 months ago
config.py barebone app with django and react, sse, jwt token, comport reader, test comport writer, requires com0com, users with groups, sample table vehicles, tokens for access and refresh 2 months ago
requirements.txt barebone app with django and react, sse, jwt token, comport reader, test comport writer, requires com0com, users with groups, sample table vehicles, tokens for access and refresh 2 months ago
test_writer.py added docker-compose for linux fixed 3 comport writer 2 weeks ago

README.md

COM Port Test Writer - Simulates device sending data

This utility simulates a physical device (like scales) by continuously writing test data to a COM port.

Features

  • Writes test data continuously to COM port
  • Multiple data types: scales, counter, random, mixed
  • Configurable write interval
  • Easy start/stop with Ctrl+C
  • List available COM ports
  • Command-line arguments

Setup

  1. Install dependencies:

    pip install -r requirements.txt
    
  2. Configure environment (optional):

    copy .env.example .env
    # Edit .env with your settings
    

Usage

List Available COM Ports

python test_writer.py --list

Basic Usage (using configured port)

python test_writer.py

Specify COM Port

python test_writer.py --port COM3

Different Data Types

Scales Data (default) - Simulates scale readings

python test_writer.py --type scales

Counter Data - Incrementing numbers

python test_writer.py --type counter

Random Data - Random numeric values

python test_writer.py --type random

Mixed Sensor Data - Temperature, humidity, pressure

python test_writer.py --type mixed

Custom Write Interval

python test_writer.py --interval 2.0  # Send every 2 seconds
python test_writer.py --interval 0.5  # Send every 0.5 seconds

Custom Baud Rate

python test_writer.py --baud 115200

Testing Workflow

  1. Start Serial Bridge (reads COM port)

    cd serial_bridge
    python app.py
    
  2. Start Test Writer (writes test data)

    cd test_comport_writer
    python test_writer.py --type scales --interval 1.0
    
  3. View in React Frontend

Configuration

Edit .env for default settings:

COM_PORT=COM1
BAUD_RATE=9600
WRITE_INTERVAL=1.0
TEST_DATA_TYPE=scales
SCALES_MIN=0
SCALES_MAX=100

Example Output

==================================================
COM Port Test Writer
==================================================
Port: COM1
Baud Rate: 9600
Data Type: scales
Write Interval: 1.0s
==================================================

✓ Connected to COM1 at 9600 baud
Press Ctrl+C to stop writing data

→ Sent: 45.23 kg
→ Sent: 45.67 kg
→ Sent: 46.12 kg
→ Sent: 46.45 kg
...
(Press Ctrl+C to stop)

✓ Disconnected from COM1
✓ Test writer stopped

Troubleshooting

  • "COM port not found": Check COM_PORT setting and ensure port exists
  • "Port already in use": Another application is using the port (close Serial Bridge temporarily)
  • No data appearing: Ensure Serial Bridge is running and pointing to same COM port
  • Baud rate mismatch: Ensure test writer and serial bridge use same baud rate

Complete System Test

To test the complete flow:

# Terminal 1: Django Backend
cd backend
venv\Scripts\activate
python manage.py runserver

# Terminal 2: React Frontend
cd frontend
npm start

# Terminal 3: Serial Bridge
cd serial_bridge
venv\Scripts\activate
python app.py

# Terminal 4: Test Writer
cd test_comport_writer
python test_writer.py --type scales --interval 1.0

Then visit http://localhost:3000 to see real-time data flow.