# modbus-rtu-electron **Repository Path**: H0110/modbus-rtu-electron ## Basic Information - **Project Name**: modbus-rtu-electron - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-15 - **Last Updated**: 2026-03-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Modbus RTU Desktop A cross-platform Electron desktop application for Modbus RTU communication over serial ports. ## Features - Serial port auto-discovery and selection - Configurable connection parameters (baud rate, parity, data bits, stop bits) - All standard Modbus function codes supported: - FC01: Read Coils - FC02: Read Discrete Inputs - FC03: Read Holding Registers - FC04: Read Input Registers - FC05: Write Single Coil - FC06: Write Single Register - FC15: Write Multiple Coils - FC16: Write Multiple Registers - Real-time activity logging - Data display with decimal, hex, and binary formats - Auto-polling with configurable interval - Data export to CSV and JSON - Dark mode theme - Auto-reconnect with configurable retry behavior ## Prerequisites - Node.js 18+ - npm or yarn ## Installation ```bash # Install dependencies npm install # Rebuild native modules for Electron npm run rebuild ``` ## Usage ### Development ```bash # Start the application npm start # Start with logging enabled npm run dev ``` ### Building ```bash # Build for current platform npm run dist # Build for specific platforms npm run dist:win # Windows npm run dist:linux # Linux npm run dist:mac # macOS ``` ## Connecting to a Modbus Device 1. Click **Refresh** to scan for available serial ports 2. Select your serial port from the dropdown 3. Configure connection parameters: - **Baud Rate**: 1200, 2400, 4800, 9600, 19200, 38400, 57600, or 115200 - **Parity**: None, Even, or Odd - **Data Bits**: 7 or 8 - **Stop Bits**: 1 or 2 - **Slave ID**: Modbus device address (1-247) - **Timeout**: Response timeout in milliseconds 4. Optionally enable **Auto-reconnect** for automatic reconnection on disconnect 5. Click **Connect** ## Reading Data 1. Select the function code (Holding Registers, Input Registers, Coils, or Discrete Inputs) 2. Enter the starting address 3. Enter the quantity to read 4. Click **Read** Results are displayed in a table with decimal, hexadecimal, and binary values. ### Auto-Polling Enable auto-polling to continuously read data at a set interval: 1. Set the polling interval (100ms - 60000ms) 2. Click **Start Poll** 3. Click **Stop Poll** to stop ## Writing Data 1. Select the function code (Single Register, Multiple Registers, Single Coil, or Multiple Coils) 2. Enter the address 3. Enter values: - For registers: decimal numbers (e.g., `100` or `100, 200, 300`) - For coils: `true`/`false` or `1`/`0` (e.g., `true` or `true, false, true`) 4. Click **Write** ## Exporting Data After reading data, export it to a file: - **Export CSV**: Spreadsheet-compatible format with headers - **Export JSON**: Structured format for programmatic use Both formats include metadata (timestamp, function code, address range). ## Auto-Reconnect Enable auto-reconnect to automatically restore connection after unexpected disconnection: 1. Enable the **Enable auto-reconnect** checkbox 2. Set the **Interval** (1-60 seconds between retry attempts) 3. Set **Max Retries** (1-10 attempts before giving up) The app will automatically attempt to reconnect if: - Connection fails initially - Connection drops unexpectedly - Too many consecutive read errors occur ## Dark Mode Click the sun/moon icon in the header to toggle between light and dark themes. Your preference is saved and persists across sessions. ## Architecture ``` ┌─────────────────────────────────────────────────────────────┐ │ Main Process (main.js) │ │ - Window management │ │ - ModbusService instance │ │ - IPC handlers │ │ - File dialog operations │ └─────────────────────────────────────────────────────────────┘ │ │ IPC ▼ ┌─────────────────────────────────────────────────────────────┐ │ Renderer Process (renderer/) │ │ - UI components │ │ - User interaction handling │ │ - Modbus API via preload.js │ │ - Theme management │ └─────────────────────────────────────────────────────────────┘ ``` ## Troubleshooting ### Serial Port Permission Denied (Linux) Add your user to the `dialout` group: ```bash sudo usermod -a -G dialout $USER # Log out and log back in for changes to take effect ``` ### Electron Sandbox Error (Linux) The app is configured to run with `--no-sandbox` by default. If you experience issues, you can also try: ```bash npx electron . --no-sandbox --disable-gpu-sandbox ``` ### Native Module Errors If you see errors related to `serialport`, rebuild native modules: ```bash npm run rebuild ``` ## License MIT