UNPKG

serialconsole

Version:

Cross-platform serial port monitor and console with TUI interface, auto-reconnect, and hex viewer. Ideal for embedded systems debugging.

294 lines (230 loc) โ€ข 11.8 kB
# ๐Ÿš€ SerialConsole [![npm version](https://badge.fury.io/js/serialconsole.svg)](https://badge.fury.io/js/serialconsole) [![npm downloads](https://img.shields.io/npm/dm/serialconsole.svg)](https://npmjs.com/package/serialconsole) [![GitHub issues](https://img.shields.io/github/issues/Sigmakib2/serialconsole)](https://github.com/Sigmakib2/serialconsole/issues) [![GitHub license](https://img.shields.io/github/license/Sigmakib2/serialconsole)](https://github.com/Sigmakib2/serialconsole/blob/main/LICENSE) [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/) A powerful cross-platform serial port monitor with interactive TUI interface, auto-reconnect, and hex viewer. Perfect for embedded systems development, Arduino programming, and hardware debugging. > **๐ŸŽ‰ Now Published on npm!** Install globally with `npm install -g serialconsole` ![SerialConsole Demo](https://raw.githubusercontent.com/Sigmakib2/serialconsole/refs/heads/main/image.png) ## โœจ Features - ๐Ÿ“Š **Interactive Port Selection** - List and select ports with baud rate configuration - ๐Ÿ–ฅ๏ธ **Responsive TUI Interface** - Professional terminal UI with real-time statistics - ๐Ÿ”„ **Auto-Reconnect** - Intelligent reconnection with exponential backoff - ๐Ÿ” **Hex Viewer** - Toggle between ASCII and hex display modes - โšก **Multiple Baud Rates** - Support for all common rates plus custom values - ๐ŸŽฎ **Nano-style Controls** - Familiar keyboard shortcuts (Ctrl+Q, Ctrl+I, etc.) - ๐Ÿ“ฑ **Cross-Platform** - Works on Windows, macOS, and Linux - ๐ŸŽฏ **Message Filtering** - Filter incoming data in real-time - ๐Ÿ“ **Multiple Modes** - Read-only, write-only, interactive, and full monitor modes ## ๐Ÿš€ Installation ### NPM (Recommended - Published Package!) ```bash # Install globally from npm npm install -g serialconsole # Alternative with short alias npm install -g serialconsole && alias sc=serialconsole # Verify installation serialconsole --version ``` ### Binary Downloads Download pre-built binaries from [Releases](https://github.com/Sigmakib2/serialconsole/releases): - **Windows**: `serialconsole-win.exe` - **macOS**: `serialconsole-macos` - **Linux**: `serialconsole-linux` ### Package Managers ```bash # NPM (Global) npm install -g serialconsole # NPX (No installation required) npx serialconsole list # Yarn (Global) yarn global add serialconsole ``` ## ๐Ÿ“– Quick Start ### Interactive Mode (Recommended) ```bash # List ports and select interactively serialconsole list # or use short alias sc list ``` **What this does:** 1. ๐Ÿ“‹ Shows all available serial ports with details 2. ๐ŸŽฏ Let you select a port by number 3. โšก Choose baud rate from common options or custom 4. ๐Ÿš€ Launches the TUI monitor automatically ### Direct Commands ```bash # Full TUI monitor serialconsole monitor /dev/ttyUSB0 -b 115200 # Simple read mode serialconsole read /dev/ttyACM0 # Send data serialconsole write /dev/ttyUSB0 "Hello Arduino" --newline # Interactive chat mode serialconsole interactive COM3 -b 9600 ``` ### Usage Examples ```bash # Arduino development workflow serialconsole list # Select Arduino port serialconsole monitor /dev/ttyACM0 -b 9600 # Monitor Arduino output # ESP32 debugging serialconsole monitor COM4 -b 115200 # Monitor ESP32 with auto-reconnect # Quick data sending serialconsole write /dev/ttyUSB0 "AT+GMR" # Send AT command ``` ## ๐ŸŽฎ TUI Controls | Key | Action | Description | |-----|--------|-------------| | `Ctrl+Q` | Exit | Close the application | | `Ctrl+I` | Send message | Open input dialog to send data | | `Ctrl+H` | Toggle hex viewer | Switch between ASCII and hex display | | `Ctrl+S` | Toggle statistics | Show/hide detailed statistics panel | | `Ctrl+P` | Pause/resume | Pause or resume data logging | | `Ctrl+C` | Clear screen | Clear all displayed messages | | `Ctrl+F` | Set filter | Filter messages by text content | | `Ctrl+E` | Toggle echo | Show/hide sent messages | | `Ctrl+L` | Line endings | Cycle through LF/CR/CRLF | | `Ctrl+R` | Auto-reconnect | Toggle automatic reconnection | ## ๐Ÿ› ๏ธ Use Cases - **๐Ÿ”ง Arduino Development** - Monitor serial output and send commands during coding - **๐Ÿ“ก ESP32/ESP8266 Projects** - Debug IoT devices with intelligent auto-reconnect - **โš™๏ธ Embedded Systems** - Professional monitoring for production debugging - **๐Ÿงช Hardware Testing** - Validate serial communication protocols - **๐Ÿ“š Educational** - Learn serial communication with visual real-time feedback - **๐Ÿฅง Raspberry Pi** - Monitor UART communication with sensors and peripherals - **๐Ÿญ Industrial IoT** - Monitor industrial devices and sensors - **๐Ÿค– Robotics** - Debug robot communication and sensor data ## ๐Ÿ“Š Interface Overview ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ ๐Ÿš€ ByteStream Monitor - /dev/ttyUSB0 โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ ๐Ÿ“ก Port: /dev/ttyUSB0 @ 115200 | ๐ŸŸข Connected | โฑ๏ธ 00:05:23 | ๐Ÿ“Š 1,247 msgs โ”‚ โ”‚ ๐Ÿ“ฅ RX: 15.2KB (51.3 B/s) | ๐Ÿ“ค TX: 2.1KB (7.1 B/s) | โ–ถ๏ธ | ๐Ÿ” | ๐Ÿ”„ โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ [14:30:25.123] โ† Temperature: 23.5ยฐC, Humidity: 45% โ”‚ โ”‚ [14:30:26.089] โ† Sensor reading complete โ”‚ โ”‚ [14:30:27.156] โ†’ status โ”‚ โ”‚ [14:30:27.201] โ† System OK - All sensors operational โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ ^Q Exit ^I Send Msg ^H Hex View ^S Statistics ^P Pause ^C Clearโ”‚ โ”‚ ^F Filter ^E Echo Mode ^L Line End ^R Auto-Reconnect โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ## โš™๏ธ Configuration ### Supported Baud Rates - **9600** (default) - Standard for many devices - **19200, 38400, 57600** - Legacy systems - **115200** - Arduino Uno/Nano standard - **230400, 460800, 921600** - High-speed communication - **Custom rates** - Any valid baud rate supported ### Line Ending Options - **LF** (`\n`) - Linux/macOS standard - **CR** (`\r`) - Classic Mac format - **CRLF** (`\r\n`) - Windows standard ### Advanced Features - **๐ŸŽฏ Real-time Filtering** - Show only messages containing specific text - **๐Ÿ”„ Smart Auto-Reconnect** - Handles device resets and power cycles - **๐Ÿ“Š Live Statistics** - Bytes sent/received, message count, uptime - **๐Ÿ” Hex Display** - View raw data in hexadecimal format - **โธ๏ธ Pause/Resume** - Pause logging without disconnecting ## ๐Ÿ”ง Advanced Usage ### Filtering Messages ```bash # Start monitoring, then press Ctrl+F # Enter "error" to show only error messages # Enter "temp" to show only temperature readings # Leave empty to disable filtering ``` ### Auto-Reconnect Workflow Perfect for development where devices reset frequently: - โœ… Automatically detects disconnections - โฑ๏ธ Exponential backoff prevents connection spam - ๐Ÿ”„ Visual countdown shows next reconnection attempt - ๐Ÿ›ก๏ธ Gracefully handles permission errors - ๐ŸŽฏ Continues where you left off ### Hex Viewer Usage ``` ASCII View: Hex View: โ† Temperature: 23.5ยฐC โ† [14:30:25] 54 65 6D 70 65 72 61 74 75 72 65 3A 20 32 33 2E 35 C2 B0 43 โ† Sensor OK โ† [14:30:26] 53 65 6E 73 6F 72 20 4F 4B ``` ## ๐Ÿšง Development ### Building from Source ```bash # Clone repository git clone https://github.com/Sigmakib2/serialconsole.git cd serialconsole # Install dependencies npm install # Run directly node index.js list # Test all commands npm test ``` ### Building Binaries ```bash # Build for all platforms npm run build:all # Build for specific platform npx pkg . --targets node18-win-x64 --compress GZip npx pkg . --targets node18-linux-x64 --compress GZip npx pkg . --targets node18-macos-x64 --compress GZip # Outputs to dist/ directory ls dist/ ``` ### Project Structure ``` serialconsole/ โ”œโ”€โ”€ index.js # Main application โ”œโ”€โ”€ package.json # Package configuration โ”œโ”€โ”€ README.md # Documentation โ”œโ”€โ”€ LICENSE # MIT license โ”œโ”€โ”€ CHANGELOG.md # Version history โ””โ”€โ”€ dist/ # Built binaries (after build) โ”œโ”€โ”€ serialconsole-win.exe โ”œโ”€โ”€ serialconsole-linux โ””โ”€โ”€ serialconsole-macos ``` ## ๐Ÿค Contributing We welcome contributions! Here's how to get started: 1. **๐Ÿด Fork** the repository 2. **๐ŸŒฟ Create** a feature branch: `git checkout -b feature-awesome-addition` 3. **๐Ÿ’ป Make** your changes with tests 4. **โœ… Commit** changes: `git commit -am 'feat: add awesome feature'` 5. **๐Ÿš€ Push** to branch: `git push origin feature-awesome-addition` 6. **๐Ÿ“ Submit** a Pull Request ### Development Guidelines - Follow existing code style and patterns - Add tests for new features - Update documentation as needed - Use conventional commit messages ## ๐Ÿ“ฆ Package Information - **๐Ÿ“‹ Package Name**: [`serialconsole`](https://npmjs.com/package/serialconsole) - **๐Ÿท๏ธ Current Version**: 1.0.0 - **๐Ÿ“„ License**: MIT - **๐Ÿ”ง Node.js**: >= 18.0.0 - **๐Ÿ’ป Platforms**: Windows, macOS, Linux (x64, ARM64) ## ๐Ÿ“ License MIT License - see [LICENSE](LICENSE) file for details. ## ๐Ÿ™ Acknowledgments - **[SerialPort](https://serialport.io/)** - Cross-platform serial communication - **[Blessed](https://github.com/chjj/blessed)** - Terminal UI framework - **[Commander.js](https://github.com/tj/commander.js)** - CLI argument parsing - **[Chalk](https://github.com/chalk/chalk)** - Terminal color styling ## ๐Ÿ› Issues & Support - ๐Ÿ› **[Report Bugs](https://github.com/Sigmakib2/serialconsole/issues/new?labels=bug)** - ๐Ÿ’ก **[Feature Requests](https://github.com/Sigmakib2/serialconsole/issues/new?labels=enhancement)** - ๐Ÿ“š **[Documentation](https://github.com/Sigmakib2/serialconsole#readme)** - ๐Ÿ’ฌ **[Discussions](https://github.com/Sigmakib2/serialconsole/discussions)** ## ๐Ÿ“ˆ Statistics Check out the package stats: - **๐Ÿ“ฆ [npm Package](https://npmjs.com/package/serialconsole)** - Downloads and version info - **๐Ÿ“Š [npm Trends](https://npmtrends.com/serialconsole)** - Usage statistics - **โญ [GitHub Stats](https://github.com/Sigmakib2/serialconsole)** - Stars and forks --- **โญ Star this repository if SerialConsole helps with your projects!** **๐Ÿš€ Install now: `npm install -g serialconsole`**