NetBurner 3.5.6
PDF Version
Serial to Serial

Serial to Serial Example

Note
Refer to the OpenAllUARTS example for your particular platform to see all possible serial configurations and pin locations

Overview

This application demonstrates a simple serial port bridge that forwards data bidirectionally between two serial ports on a NetBurner embedded system. The program uses the select() function to efficiently monitor both serial ports simultaneously and forward data from one port to the other in real-time.

Description

The Serial to Serial example opens two serial ports and creates a bridge between them, allowing data sent to one port to be automatically forwarded to the other port. This is useful for applications such as:

  • Serial port debugging and monitoring
  • Creating a serial bridge between different devices
  • Testing serial communication systems
  • Bridging different serial interfaces

Key Features

  • Bidirectional Communication: Data flows in both directions between the two serial ports
  • Interrupt-Driven Mode: Uses buffered interrupt-driven serial communication for efficient operation
  • Non-blocking I/O: Utilizes the select() function to monitor multiple file descriptors simultaneously
  • Configurable Timeout: Uses a 5-second timeout for the select operation
  • LED Indicators: On MOD5441X platforms, LEDs indicate when data is being transferred

Technical Implementation

Serial Port Configuration

Both serial ports are configured with identical settings:

  • Baud Rate: 115,200 bps
  • Stop Bits: 1
  • Data Bits: 8
  • Parity: None

Operation Flow

  1. Initialization:
    • System initialization and network startup
    • Serial ports are closed (they start in polled mode from monitor)
    • Serial ports are reopened in interrupt-driven mode
  2. Initial Test:
    • Sends "Test1" to serial port 1
    • Sends "Test0" to serial port 0
  3. Main Loop:
    • Sets up file descriptor set for both serial ports
    • Uses select() to wait for data on either port (5-second timeout)
    • When data arrives on port 1, forwards it to port 0
    • When data arrives on port 0, forwards it to port 1
    • On MOD5441X platforms, toggles LEDs to indicate activity

Buffer Management

  • Uses 40-byte buffers for data transfer
  • Reads available data and immediately forwards it to the opposite port
  • No data modification or processing - pure pass-through operation

Hardware Requirements

  • NetBurner embedded system with at least two serial ports
  • Compatible with MOD5441X platforms (includes LED indicators)
  • Serial devices or cables connected to both serial ports for testing

Usage

  1. Connect serial devices or use serial cables to connect to both serial ports
  2. Compile and deploy the application to your NetBurner device
  3. Power on the device - it will automatically start bridging the serial ports
  4. Send data to either serial port and observe it being forwarded to the other port
  5. On MOD5441X platforms, watch for LED activity indicating data transfer

Code Structure

  • Initialization: Sets up the system and network
  • Serial Port Setup: Configures both serial ports for interrupt-driven operation
  • Main Loop: Implements the select-based data forwarding logic
  • Platform-Specific Features: Conditional LED control for supported platforms

Notes

  • The system diagnostics are enabled in this example but should be removed for production code
  • The application waits up to 5 seconds for network activation at startup
  • The select timeout of 5 seconds means the loop will cycle even if no data is received
  • This is a blocking application that runs indefinitely