NetBurner 3.5.6
PDF Version
Remote Web Console for Serial/stdout

NetBurner Remote Web Console Example

Overview

This example demonstrates the Remote Web Console feature for NetBurner devices. The Remote Web Console creates a web-based interface that redirects the device's stdout output (normally sent to the USB serial port or DB9) to a webpage accessible at http://your-device-ip/console.html. For example, a printf("Hello Wolrd"); in the application will appear in the web page console window just as it would a serial port terminal.

The Remote Console can be added to any application with:

This feature is particularly useful for:

  • Remote debugging and monitoring
  • Accessing device output without physical USB connection
  • Web-based device interaction and command input
  • Development and troubleshooting in network environments

Features

  • Web-based Console: Access device output through any web browser
  • Real-time Output: Stdout redirected to web interface
  • Interactive Commands: Simple command processing demonstration
  • Network Accessibility: Remote access via device IP address

Files Description

main.cpp

The main application file containing:

  • Network stack initialization
  • HTTP server startup
  • Remote console enablement
  • Simple command processing loop
  • Periodic status output

ReadMe.txt

Documentation file explaining the Remote Web Console implementation and usage.

Implementation Details

Key Components

  1. Network Initialization
    init(); // Initialize network stack
    #define TICKS_PER_SECOND
    System clock ticks per second.
    Definition constants.h:49
    void StartHttp(uint16_t port, bool RunConfigMirror)
    Start the HTTP web server. Further documentation in the Initialization section Initialization - Syste...
    void init()
    System initialization. Ideally called at the beginning of all applications, since the easiest Recover...
    bool WaitForActiveNetwork(uint32_t ticks_to_wait=120 *TICKS_PER_SECOND, int interface=-1)
    Wait for an active network connection on at least one interface.
  2. Remote Console Setup
    #include <remoteconsole.h>
    void EnableRemoteConsole()
    Enables the remote webconsole feature.
  3. Command Processing
    • Listens for character input
    • Responds to 'h' command with "Hello!"
    • Provides feedback for unknown commands
    • Outputs periodic status dots

Required Headers

Usage Instructions

Building and Deploying

  1. Compile the Application
    • Use NetBurner development tools to build the project
    • Ensure all required libraries are linked
  2. Deploy to Device
    • Flash the compiled binary to your NetBurner device
    • Connect the device to your network
  3. Network Configuration
    • Ensure the device obtains an IP address
    • Note the device's IP address for web access

Accessing the Web Console

  1. Open Web Browser
    • Navigate to http://[device-ip]/console.html
    • Replace [device-ip] with your device's actual IP address
  2. Interact with Console
    • View real-time output from the device
    • Send commands through the web interface
    • Monitor periodic status updates (dots every second)

Available Commands

  • **'h'**: Displays "Hello!" message
  • Other characters: Shows "Unknown command" message
  • Periodic Output: Status dots appear every second

Technical Notes

System Diagnostics

void EnableSystemDiagnostics()
Turn on the diagnostic reports from the config page.
  • Enabled for development and debugging
  • Consider disabling for production deployments

Timing and Delays

OSTimeDly(TICKS_PER_SECOND);
  • Main loop executes every second
  • Provides regular status updates
  • Prevents excessive CPU usage

Network Dependencies

  • Requires active network connection
  • HTTP server must be running
  • Device must be accessible via IP address

Customization Options

Extending Commands

Add more command processing in the main loop:

if (c == 'h')
{
printf("\r\nHello!\r\n");
}
else if (c == 's')
{
printf("\r\nStatus: Running\r\n");
}
// Add more commands here

Modifying Output Frequency

Change the delay value to adjust status update frequency:

OSTimeDly(TICKS_PER_SECOND * 2); // 2-second intervals

Adding Application Logic

Insert your application-specific code within the main loop while preserving the console functionality.

Troubleshooting

Common Issues

  1. Cannot Access Web Console
    • Verify device IP address
    • Check network connectivity
    • Ensure HTTP server is running
    • Confirm firewall settings
  2. No Output Visible
    • Check if RemoteConsole is enabled
    • Verify printf statements are executing
    • Ensure web page is properly loaded
  3. Commands Not Responding
    • Verify character input handling
    • Check if charavail() is functioning
    • Ensure main loop is executing

Debug Steps

  1. Monitor USB serial output during development
  2. Use network tools to verify device connectivity
  3. Check HTTP server status and logs
  4. Verify application is running and not stuck