NetBurner 3.5.6
PDF Version
Serial Webserver

Serial Webserver

A NetBurner RTOS application that bridges serial communication with HTTP web services, allowing HTTP requests to be received and processed over a serial port connection.

Overview

The Serial Webserver demonstrates how to create a bidirectional communication bridge between a serial port and TCP/HTTP connections. This application enables HTTP requests to be sent over a serial connection and receive corresponding web responses back through the same serial interface.

It will receive and reply to HTTP requests over a serial port, using the NetBurner web server implementation. The example will display a Hello World message on the device's index page index.html.

Key Features

  • Serial-to-HTTP Bridge: Receives HTTP requests via serial port and forwards them to the built-in web server
  • Bidirectional Communication: Splices data between serial and TCP connections in both directions
  • Automatic Connection Management: Handles TCP connection creation and cleanup automatically
  • Error Recovery: Automatically reopens serial connections on errors
  • Built-in Web Server: Serves static content including HTML, CSS, and images

Technical Specifications

  • Serial Port: Port 1 at 115200 baud
  • HTTP Port: Standard port 80
  • Buffer Size: Uses Ethernet buffer size for data transfer
  • Network Stack: NetBurner RTOS with TCP/IP support

Application Architecture

The application follows a simple event-driven architecture:

  1. Initialization: Sets up network stack, enables diagnostics, and starts HTTP server
  2. Serial Monitoring: Waits for incoming serial data
  3. Connection Creation: Establishes TCP connection to local web server when data arrives
  4. Data Splicing: Uses select() to monitor both serial and TCP file descriptors
  5. Bidirectional Transfer: Forwards data between serial and TCP connections
  6. Error Handling: Closes and reopens connections on errors

HTTP Request Format

The application expects standard HTTP requests over the serial connection. A typical request format:

GET /INDEX.HTML HTTP/1.1\r\n\r\n

Important**: The web server requires a double carriage return line feed (\r\n\r\n) to properly parse HTTP requests.

Expected Response

A successful request to the index page returns:

HTTP/1.0 200 OK
Pragma: no-cache
MIME-version: 1.0
Content-Type: text/html
Content-length: 231
<html>
<head><link rel="stylesheet" type="text/css" href="style.css"></head>
<body>
<a href="http://www.netburner.com"><img src="logo.jpg" width="200" border="0"></a>
<h1>Thank you for NetBurning!</h1>
</body>
</html>

Web Content

The application serves the following static files:

  • index.html: Main page with NetBurner branding and welcome message
  • style.css: Stylesheet defining Arial font family for the page
  • logo.jpg: NetBurner logo image (referenced but not included in source)

Usage

  1. Flash the application to your NetBurner device
  2. Connect to the device's serial port (Port 1, 115200 baud)
  3. Send HTTP requests through the serial connection
  4. Receive HTTP responses back through the same serial connection

Development Notes

  • System diagnostics are enabled for development (consider removing for production)
  • The application uses blocking I/O operations
  • Memory allocation uses FAST_USER_VAR for the splice buffer

Use Cases

This application is ideal for:

  • Testing HTTP communication through serial interfaces
  • Bridging legacy serial devices to modern web services
  • Remote web server access through serial connections

Build Requirements

  • NetBurner NBRTOS development environment
  • Standard NetBurner libraries (init, system, iosys, serial, tcp, netinterface)
  • Compatible NetBurner hardware platform