A lightweight, single-file Python CLI application to record, preview, parse, and log serial port data into a CSV file with local ISO timestamps.
First you need to have Python 3.8 or greater installed on your machine. Then install the requirements:
pip install pyserialRun without arguments to start the step-by-step interactive configuration:
python main.pyTo skip configuration and run directly (serial port selection is always prompted):
python main.py serial_config.json- Local ISO 8601 Timestamps: Every CSV row is timestamped with local time and timezone offset (e.g.
2026-08-04T11:26:00.771162+02:00). - Parsing Modes:
- Field Delimiter: Split lines by comma
,, tab\t, space, semicolon;, or custom string. - Regex Named Groups: Optional regex parsing supporting
(?'name'...)or(?<name>...)syntax, automatically extracting column names from capture group names.
- Field Delimiter: Split lines by comma
- Malformed Line Handling: Choose whether to log raw un-parsed text or discard malformed lines.
- Smart Adaptive Flushing: Flushes data to disk when serial buffers drain or periodically (every 1s), preventing I/O bottlenecks during high-frequency data streams while preserving real-time output.
- Robust Error Handling: Catches unexpected serial port disconnections and handles
Ctrl+Ccleanly without tracebacks.
Test the logger without physical serial hardware using the built-in PTY simulator:
Terminal 1: Run simulator (creates a virtual serial port like /dev/pts/X)
python test.py --loop --delay 0.5Terminal 2: Run logger and select the virtual port (/dev/pts/X)
python main.py{
"baudrate": 115200,
"bytesize": 8,
"parity": "N",
"stopbits": 1.0,
"timeout": 1.0,
"encoding": "utf-8",
"newline": "\n",
"strip_whitespace": true,
"use_regex": true,
"regex_pattern": "^\"(?'volts'[^\"]*)\",(?'amps'\\d+\\.\\d+)$",
"columns": ["volts", "amps"],
"mismatch_action": "discard"
}Created by SZEnergy Team for Shell Eco Marathon
- Váradi Marcell (varma02@GitHub)