System Diagnostics Example
Overview
This application demonstrates how to integrate system diagnostics into a NetBurner device application. The program enables a web-based diagnostic interface that displays both system information and custom application variables through the device's Configuration Server web page.
Features
- System Diagnostics: Enables built-in system diagnostic information display
- Custom Variable Monitoring: Demonstrates how to add application-specific variables to the diagnostic web page
- Web Interface: Provides access to diagnostics through HTTP server on port 80
- Real-time Updates: Variables are updated in real-time and can be monitored through the web interface
Application Components
Main Functionality
The application performs the following operations:
- Initializes the network stack
- Enables system diagnostics functionality
- Starts the HTTP web server on default port 80
- Waits for network connectivity
- Continuously increments a counter variable every second
Monitored Variables
The application includes two example variables that are displayed on the diagnostic web page:
- myInt: An integer counter that increments every second
- myString: A string variable initialized with "My String Variable"
Code Structure
Key Components
- Network Initialization: Standard NetBurner network stack setup
- Diagnostic Integration: Uses
EnableSystemDiagnostics()
to activate the diagnostic interface
- Variable Monitoring: Implements
DiagVarMon
and DiagStrMon
for custom variable display
- Web Server: HTTP server provides access to the diagnostic interface
Header Dependencies
#include <string.h>
NetBurner Diagnostics System.
NetBurner System Initialization Header File.
NetBurner Real-Time Operating System (NBRTOS) API.
NetBurner System Functions.
Usage Instructions
Building and Running
- Compile the application using the NetBurner development tools
- Deploy to your NetBurner device
- Ensure the device is connected to your network
- The application will display network information on the console
Accessing Diagnostics
- Open a web browser
- Navigate to your device's IP address (port 80)
- Access the Configuration Server web page
- Click the "Diagnostics" button to view system and application variables
Adding Custom Variables
To add your own variables to the diagnostic display:
For Integer Variables
int yourVariable;
static DiagVarMon YourVarMon(
"Variable Description", yourVariable);
Monitor and report the value of numeric variables.
Definition diagnostics.h:97
For String Variables
char yourString[SIZE];
static DiagStrMon YourStrMon(
"String Description", yourString);
Monitor and report string values.
Definition diagnostics.h:242
Supported Variable Types
- Integers (
DiagVarMon
)
- Strings (
DiagStrMon
)
- Floats (using appropriate diagnostic monitor classes)
- Other data types as supported by the diagnostics library
Important Notes
Production Considerations
- The
EnableSystemDiagnostics()
function should likely be removed or conditionally compiled for production code
- Consider security implications of exposing diagnostic information in production environments
- The web server runs on port 80 by default and may conflict with other web services
Network Requirements
- Device must be connected to an active network
- The application waits up to 5 seconds for network connectivity before proceeding
- HTTP server accessibility depends on network configuration and firewall settings
Output Example
When running, the application displays:
Web Application: System Diagnostics Example
NNDK Revision: [Current NetBurner SDK Version]
The web diagnostic interface will show:
- Standard system diagnostic information
- "My Int": Incrementing counter value
- "My String": "My String Variable"