NetBurner 3.5.6
PDF Version
UDP to Serial

NetBurner UDP to Serial Bridge

A NetBurner embedded application that provides bidirectional communication between UDP network traffic and a serial port interface.

Overview

This application acts as a bridge between UDP network packets and serial communication, enabling remote devices to communicate with serial-connected equipment over a network. It's particularly useful for:

  • Remote monitoring and control of serial devices
  • Network-enabling legacy serial equipment
  • Creating distributed serial communication systems
  • Debugging and testing serial protocols over network

Features

  • Bidirectional Communication: Data flows seamlessly between UDP and serial interfaces
  • Web-based Configuration: Easy setup through browser interface
  • Configurable Parameters: Customizable baud rates, ports, and IP addresses
  • Real-time Operation: Low-latency data transfer with select() based I/O
  • Remote Console: Web-based console access for monitoring and debugging
  • Persistent Settings: Configuration stored in non-volatile memory

Architecture

The application consists of two main communication paths:

UDP to Serial (UdpReaderMain Task)

  • Listens for incoming UDP packets on configured port
  • Forwards received data to the serial port
  • Displays packet information for debugging

Serial to UDP (UserMain Task)

  • Monitors serial port for incoming data using select()
  • Packages serial data into UDP packets
  • Sends packets to configured destination IP and port

Configuration Parameters

Parameter Default Value Description
UDP Listen Port 24 Local port for receiving UDP packets
UDP Destination Port 8888 Remote port for sending serial data
UDP Destination IP 192.168.1.188 Remote IP address for outgoing packets
Serial Baud Rate 115200 Serial communication speed
Serial Port 1 Physical serial port number

Available Baud Rates

  • 9600
  • 19200
  • 38400
  • 57600
  • 115200
  • 234000

File Structure

main.cpp # Main application logic and UDP/Serial handlers
nvsettings.h # Configuration class definitions
htmlvars.h # Web interface variable declarations
index.html # Web configuration interface
style.css # Web interface styling

Hardware Configuration

  • Data Serial Port: Port 1 (configurable baud rate)
  • Debug Serial Port: Port 0 (115200 baud, fixed).
  • Serial Parameters: 8 data bits, 1 stop bit, no parity
Note
Debug serial port can be viewed on the console.html web page.

Network Configuration

The application automatically:

  • Waits for DHCP network configuration
  • Starts HTTP server on port 80
  • Enables remote console access via web browser

Web Interface

Access the configuration interface by navigating to http://[device-ip]/ in a web browser. The interface allows real-time modification of:

  • UDP listen port
  • Destination IP address and port
  • Serial baud rate

Visit http://[device-ip]/console.html for real-time console output and debugging information.

Usage Examples

Example 1: Serial Device Monitoring

Configure the bridge to receive data from a serial sensor and forward it to a network monitoring system:

  • Set destination IP to your monitoring server
  • Configure appropriate baud rate for your sensor
  • Monitor data flow through the web console

Example 2: Remote Serial Control

Send commands to a serial device from a network application:

  • Configure UDP listen port (e.g., 24)
  • Send UDP packets containing serial commands to the bridge
  • Commands are automatically forwarded to the serial device

Protocol Details

UDP Packet Structure

  • Source Port: 8889 (fixed for outgoing packets)
  • Destination Port: Configurable
  • Data: Serial data plus null terminator and padding bytes
  • Padding: 4 additional zero bytes added to prevent packet filtering

Serial Configuration

  • Data Bits: 8
  • Stop Bits: 1
  • Parity: None
  • Flow Control: None

Debugging and Monitoring

The application provides debugging output:

  • UDP packet reception notifications with source information
  • Serial data transmission confirmations
  • Configuration parameter display on startup
  • Real-time data flow visualization
Note
A python program is included for UDP packet receive on a host computer: ReceiveUDP.py.

All debug information is available through:

  • Serial console (UART0 at 115200 baud)
  • Web console interface (http://[device-ip]/console.html)

Building and Deployment

This application is designed for the NetBurner embedded platform and requires:

  • NetBurner NNDK (NetBurner Network Development Kit)
  • Compatible NetBurner hardware module
  • Network connectivity (Ethernet)
  • Serial interface hardware

Technical Notes

  • Uses NetBurner RTOS for multitasking
  • Implements I/O with select() for optimal performance
  • Configuration changes require restart
  • UDP packets with minimal data include padding to prevent firewall filtering
  • Thread-safe operation with separate tasks for each communication direction

Troubleshooting

Common Issues

  1. No UDP Traffic: Check firewall settings and network connectivity
  2. Serial Communication Problems: Verify baud rate and wiring
  3. Configuration Not Saved: Ensure proper form submission through web interface

Debug Steps

  1. Monitor web console for real-time status
  2. Verify network configuration (DHCP assignment)
  3. Test serial port with external terminal program
  4. Use network packet capture tools to verify UDP traffic