# ser2telnetd **Repository Path**: mudash/ser2telnetd ## Basic Information - **Project Name**: ser2telnetd - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-19 - **Last Updated**: 2026-06-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Serial-to-Telnet Server A Windows-based serial port to Telnet server that supports multiple clients, data broadcasting, client timeout management, and performance testing. ## Features - **Serial to Telnet Bridge**: Connect serial devices (COM ports) to network via Telnet - **Multi-client Support**: Multiple Telnet clients can connect simultaneously - **Data Broadcasting**: Serial data is broadcasted to all connected clients - **Echo Mode**: Test mode without requiring physical serial hardware - **Client Timeout**: Automatically disconnects inactive clients - **Performance Testing**: Built-in timing and data comparison tools - **Microsecond Precision**: High-resolution timestamp logging ## Directory Structure ``` ser2telnetd/ ├── docs/ # Documentation │ ├── design_doc.md # System design document │ └── test_doc.md # Test cases document ├── inc/ # Header files │ ├── serial.h # Serial port module │ └── telnet_server.h # Telnet server module ├── src/ # Source code │ ├── ser2telnetd.c # Main server program │ ├── serial.c # Serial port implementation │ ├── telnet_server.c # Telnet server implementation │ └── telnet_client.c # Telnet client for testing ├── test/ # Test suite │ ├── main.c # Test runner │ ├── test.h # Test framework │ ├── test_serial.c # Serial module tests │ ├── test_telnet.c # Telnet module tests │ ├── test_main.c # Main program tests │ ├── test_integration.c # Integration tests │ ├── test_boundary.c # Boundary tests │ ├── test_network.c # Network tests │ └── test_serial_actual.c # Actual serial tests ├── scripts/ # Build scripts │ ├── build_all.bat # Build all binaries │ └── build_tests.bat # Build test suite ├── build/ # Build output (generated) └── .gitignore # Git ignore rules ``` ## Requirements - Windows 10/11 - Visual Studio 2022 (for compilation) - MSVC compiler (cl.exe) - Windows SDK (10.0.22621.0) ## Compilation ### Build All ```batch cd scripts build_all.bat ``` ### Build Server Only ```batch cl /Fe:build\ser2telnetd.exe src\ser2telnetd.c src\serial.c src\telnet_server.c /link ws2_32.lib ``` ### Build Client Only ```batch cl /Fe:build\telnet_client.exe src\telnet_client.c /link ws2_32.lib ``` ### Build Tests ```batch cd scripts build_tests.bat ``` ## Usage ### Server - Serial Mode ```batch ser2telnetd.exe [timeout] Example: ser2telnetd.exe COM3 115200 2323 60 ``` ### Server - Echo Mode (Testing) ```batch ser2telnetd.exe none 115200 2323 60 ``` In echo mode, client data is echoed back without requiring serial hardware. ### Client ```batch telnet_client.exe Example: telnet_client.exe localhost 2323 ``` ## Command Line Parameters | Parameter | Description | Required | | :--- | :--- | :--- | | serial_port | Serial port name (e.g., COM1, COM3) or "none" for echo mode | Yes | | baud_rate | Serial baud rate (e.g., 9600, 115200) | Yes | | telnet_port | Telnet server port (1-65535) | Yes | | timeout | Client timeout in seconds (default: 60) | No | ## Testing ### Run Tests ```batch build\tests.exe ``` ### Performance Testing Use echo mode with the Telnet client for performance testing: ```batch # Start server in echo mode ser2telnetd.exe none 115200 2323 60 # Connect client (in another terminal) telnet_client.exe localhost 2323 ``` The client will display: - Send/receive timestamps (microsecond precision) - Round-trip time calculation - Data comparison results - Summary statistics ## Test Output Example ``` [INFO] Connected to localhost:2323 [INFO] Type 'quit' to exit [INFO] Other input will be sent and compared with echoed data ---------------------------------------- [TEST-001] [SEND ] Time: 494952:44:47.134321, 6 bytes hello [RECV ] Time: 494952:44:47.134321, 6 bytes [STATS ] Round-trip time: 0 us (0.000 ms) [MATCH ] SUCCESS: Data matched! ======================================== Summary: 1 tests performed Success: 1/1 Min round-trip: 0 us (0.000 ms) Max round-trip: 0 us (0.000 ms) Avg round-trip: 0.000 ms ======================================== ``` ## Log Format Server logs use microsecond-precision timestamps: ``` [2026-06-19 08:44:24.290256] INFO Server Running in echo mode [2026-06-19 08:44:24.295547] INFO Server Telnet server listening on port 2323 [2026-06-19 08:44:25.123456] INFO Client Client connected: 127.0.0.1 ``` ## Architecture ### Modules 1. **ser2telnetd**: Main program with initialization and event loop 2. **serial**: Serial port communication (open, close, read, write) 3. **telnet_server**: TCP server with client management and broadcasting 4. **telnet_client**: Testing client with timing and comparison features ### Data Flow ``` Serial Port ──► serial_read() ──► telnet_broadcast() ──► All Clients ▲ │ │ │ └─────────────────── serial_write() ◄─────────────────────┘ (from any client) ``` ## Known Issues - Serial port must be available and not in use by other applications - Echo mode does not require serial hardware - Firewall may need to allow incoming connections on the Telnet port ## License This project is for internal use. All rights reserved. ## Version History | Version | Date | Changes | | :--- | :--- | :--- | | 1.0 | 2026-06-19 | Initial release with basic serial-to-Telnet functionality | | 1.1 | 2026-06-19 | Added echo mode for testing | | 1.2 | 2026-06-19 | Added microsecond timestamp logging | | 1.3 | 2026-06-19 | Added Telnet client with timing features | | 1.4 | 2026-06-19 | Added data comparison and statistics |