MSXシリアルターミナル
Project description
MSX Serial Terminal
A high-performance terminal program for MSX communication via serial connection or telnet. Features instant character display, automatic mode detection, and Japanese text support.
Features
✨ Instant Communication: Optimized for real-time character-by-character MSX interaction
🔍 Automatic Mode Detection: Detects BASIC and MSX-DOS modes automatically
🌐 Multiple Connection Types: Serial, Telnet, and Dummy connections
📝 Japanese Text Support: Full MSX character encoding support
📁 File Transfer: BASIC program upload and text file paste functionality
🎯 Smart Completion: Context-aware command completion
🎨 Color Display: Beautiful colored terminal output
Installation
pip install msx-serial
Usage
Basic Connection
# Serial connections
msx-serial COM1 # Windows
msx-serial /dev/ttyUSB0 # Linux
msx-serial /dev/tty.usbserial-12345678901 # macOS
# Serial with parameters
msx-serial 'serial:///dev/ttyUSB0?baudrate=115200&bytesize=8&parity=N&stopbits=1'
# Telnet connections
msx-serial 192.168.1.100:2223
msx-serial telnet://192.168.1.100:2223
# Dummy connection (for testing)
msx-serial dummy://
Command Line Options
usage: msx-serial [-h] [--encoding ENCODING] [--debug] connection
MSX Serial Terminal
positional arguments:
connection Connection string (e.g. COM4, /dev/ttyUSB0, 192.168.1.100:2223, dummy://)
options:
-h, --help Show help message and exit
--encoding ENCODING Text encoding (default: msx-jp)
--debug Enable debug mode
Special Commands
| Command | Description | Available In |
|---|---|---|
@paste |
Paste text file content | BASIC mode only |
@upload |
Upload file as BASIC program | BASIC mode only |
@cd |
Change current directory | All modes |
@encode |
Set text encoding | All modes |
@help |
Show command help | All modes |
@mode |
Display/force MSX mode | All modes |
@exit |
Exit program | All modes |
Use @help for detailed command usage information.
MSX Mode Detection
The terminal automatically detects and adapts to MSX operating modes:
- BASIC Mode: Detected by
Okprompt - enables file upload/paste commands - MSX-DOS Mode: Detected by
A:>,B:>,C:>etc. prompts - Unknown Mode: Default state until mode is detected
Mode Commands
@mode # Display current MSX mode
@mode basic # Force BASIC mode
@mode dos # Force MSX-DOS mode
@mode unknown # Reset to unknown mode
Connection URI Format
Serial Connections
# Basic format
serial:///dev/ttyUSB0
# With parameters
serial:///dev/ttyUSB0?baudrate=115200&bytesize=8&parity=N&stopbits=1&timeout=1
Supported Parameters:
baudrate: Baud rate (default: 9600)bytesize: Data bits (5, 6, 7, 8 - default: 8)parity: Parity (N, E, O, M, S - default: N)stopbits: Stop bits (1, 1.5, 2 - default: 1)timeout: Read timeout in secondsxonxoff: Software flow control (true/false)rtscts: Hardware flow control (true/false)dsrdtr: DSR/DTR flow control (true/false)
Telnet Connections
# Basic format
telnet://hostname:port
# Examples
telnet://192.168.1.100:2223
telnet://msx.local:2223
Text Encoding Support
Supported encodings for MSX text:
msx-jp: Japanese MSX encoding (default)msx-intl: International MSX encodingmsx-br: Brazilian MSX encodingshift-jis: Shift-JIS encodingutf-8: UTF-8 encoding
Change encoding with: @encode msx-jp
Architecture
Core Components
- OptimizedTerminalSession: Main terminal session with instant response
- ConnectionManager: Unified connection handling (Serial/Telnet/Dummy)
- MSXProtocolDetector: Automatic mode detection from prompts
- DataProcessor: Real-time data processing with instant display
- CommandCompleter: Context-aware command completion
- FileTransferManager: File upload and paste operations
Project Structure
msx_serial/
├── core/ # Core terminal session and data processing
├── connection/ # Connection implementations (Serial/Telnet/Dummy)
├── protocol/ # MSX protocol detection and mode management
├── display/ # Terminal display handlers
├── completion/ # Command completion system
├── commands/ # Special command handlers
├── io/ # Input/output coordination
├── transfer/ # File transfer functionality
├── common/ # Shared utilities and color output
└── data/ # Static data (command lists, keywords)
Key Design Principles
- Instant Response: Character-by-character processing for real-time MSX interaction
- Automatic Adaptation: Mode detection adapts terminal behavior to MSX state
- Unified Connection: Single interface for multiple connection types
- Context Awareness: Commands and completion adapt to current MSX mode
- Robust Error Handling: Graceful handling of connection and encoding issues
Development
Requirements
- Python 3.9+
- Dependencies listed in
pyproject.toml
Setup Development Environment
# Clone repository
git clone https://github.com/yamamo-to/msx-serial
cd msx-serial
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/macOS
# or
.\venv\Scripts\activate # Windows
# Install in development mode
pip install -e . --use-pep517
Running Tests
# Run all tests
python -m pytest
# Run with coverage
python -m pytest --cov=msx_serial
# Run specific test file
python -m pytest tests/test_protocol.py -v
Key Dependencies
- pyserial: Serial communication
- prompt-toolkit: Interactive command line interface
- colorama: Terminal color support
- msx-charset: MSX character encoding conversion
- chardet: Character encoding detection
- PyYAML: YAML configuration file support
- tqdm: Progress bars for file transfers
Performance Optimizations
The terminal is optimized for MSX communication with several key improvements:
- Instant Mode: Character-by-character processing eliminates buffering delays
- Adaptive Delays: Smart timing based on data activity patterns
- Efficient Display: Direct ANSI escape sequence output
- Single Character Reads: Optimal for MSX's character-based interaction
- Echo Suppression: Intelligent command echo handling
Acknowledgments
Base64 upload functionality inspired by: https://qiita.com/enu7/items/23cab122141fb8d07c6d
MSX-BASIC command reference converted from: https://github.com/fu-sen/MSX-BASIC
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file msx_serial-0.2.14.tar.gz.
File metadata
- Download URL: msx_serial-0.2.14.tar.gz
- Upload date:
- Size: 125.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c43000205e1123d9fe5a7a1da83f3a11a78aa579eefdb5665c027f391024abab
|
|
| MD5 |
48d6b723b62d3c19fa77a434501c30e6
|
|
| BLAKE2b-256 |
d9680add1cca842c6fe3ce381d391f1a88dd4f75281ceef702a1306531ca5e39
|
File details
Details for the file msx_serial-0.2.14-py3-none-any.whl.
File metadata
- Download URL: msx_serial-0.2.14-py3-none-any.whl
- Upload date:
- Size: 199.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b623c517d6b9b44d2ac87031afa9c97ffea0d85a92af3300e1dd623fca0c795
|
|
| MD5 |
a2df63ccada0b8aaf9dd824939227fe8
|
|
| BLAKE2b-256 |
3f635c2eddf604fb591be40bfb3c15110ebff5ecf7575b1f2fcd0faf72ef7724
|