TCP to Serial Bridge
A NetBurner embedded application that creates a bidirectional bridge between TCP network connections and serial communication ports.
Overview
This application enables remote access to serial devices over a network by creating a TCP server that forwards data between network clients and a serial port. It's commonly used for remote device management, debugging, and data acquisition from serial-based equipment.
- Note
- You can test with on a single PC by using a telnet application and serial terminal like MTTTY
Features
- Bidirectional Communication: Data flows seamlessly between TCP clients and serial devices
- Telnet Compatible: Listens on port 23 (standard Telnet port) for easy connection
- Connection Management: Handles multiple connection attempts with configurable override behavior
- Timeout Protection: Automatically closes idle connections after 60 seconds
- Multi-Platform Support: Supports various NetBurner platforms (SOMRT1061, MODRT1171, SB800EX)
- Status Monitoring: Provides connection status messages to both serial and network interfaces
Configuration
Serial Port Settings
- Baud Rate: 115,200 bps
- Data Bits: 8
- Stop Bits: 1
- Parity: None
Network Settings
- TCP Listen Port: 23 (Telnet)
- Connection Timeout: 60 seconds of inactivity
- Override Timeout: 20 seconds (configurable)
Connection Override Behavior
The application supports three modes for handling new connections when one is already active:
- Ignore New Connections (
OVERIDE_TIMEOUT = 0xFFFFFFFF)
- Maintains current connection, rejects new attempts
- Timed Override (
OVERIDE_TIMEOUT = 20 seconds)
- Allows new connection to replace existing one after 20 seconds of current connection activity
- Always Override (
OVERIDE_TIMEOUT = 0)
- Immediately replaces existing connection with new one
Platform Support
The application automatically configures pins for different NetBurner platforms where necessary:
- SOMRT1061: Uses LPUART4 on pins 87 (RX), 88 (TX), with flow control on pins 2 (RTS), 3 (CTS)
- MODRT1171: Uses LPUART2 on pins 21 (RX), 22 (TX)
- SB800EX: Uses UART2
Notes for SOMRT1061
- The console port for status messages is J13 on the development board, which is routed to LPUART3 on the processor.
- The data port is J14 on the development board, which is routed to LPUART4 on the processor.
- RX, TX, RTS, CTS pin selection is always required before opening the serial port.
- Note
- Refer to the OpenAllUARTS example for your particular platform to see all possible pin configurations.
Usage
- Compile and Deploy: Build the application for your NetBurner platform and deploy to the device
- Connect Serial Device: Attach your serial device to the configured UART pins
- Network Connection: Connect via Telnet client to the device's IP address on port 23
telnet <device-ip-address> 23
- Data Exchange: Data typed in the Telnet session is sent to the serial device, and serial responses appear in the Telnet session
Status Messages
The application provides informative status messages:
To Serial Port:**
Technical Details
- Uses NetBurner's RTOS with select() for efficient I/O multiplexing
- Implements proper socket management with error handling
- Supports hardware flow control (RTS/CTS) where available
- Buffer size: 40 bytes for data transfers
- Non-blocking I/O operations for responsive performance
Use Cases
- Remote serial device configuration and monitoring
- Data logging from serial sensors over network
- Remote debugging of embedded systems
- Industrial automation equipment access
- Legacy serial device integration into modern networks
Requirements
- NetBurner development kit
- NetBurner development environment
- Network connectivity (Ethernet)
- Serial device or equipment to bridge
Notes
- Ensure proper pin configuration for your specific NetBurner platform
- Test connection override behavior matches your application requirements