ModifyEthernet Configuration Example
Overview
This NetBurner example demonstrates how to view and modify Ethernet interface configuration parameters using the embedded system configuration system. The application provides an interactive command-line interface for managing network settings that are stored persistently in the device's configuration record.
Features
- Interactive command-line interface for network configuration
- Persistent storage of configuration changes
- Real-time modification of network parameters
- Configuration tree visualization
- Support for multiple IP configuration modes
- Automatic configuration validation and saving
Project Structure
ModifyEthernet/
├── src/
│ └── main.cpp # Main application with interactive interface
└── makefile # Build configuration
Architecture
System Components
┌───────────────────────────────────────────────────────────────────────┐
│ NetBurner Configuration System │
├───────────────────────────────────────────────────────────────────────┤
│ Configuration Parameters │
│ ┌──────────────────┐ ┌──────────────────┐ ┌─────────────────────┐ │
│ │ Network Settings │ │ Device Identity │ │ Discovery Settings │ │
│ │ │ │ │ │ │ │
│ │ • IPv4 Address │ │ • Device Name │ │ • Server URL │ │
│ │ • Gateway │ │ │ │ │ │
│ │ • Subnet Mask │ │ │ │ │ │
│ │ • IP Mode │ │ │ │ │ │
│ └──────────────────┘ └──────────────────┘ └─────────────────────┘ │
├───────────────────────────────────────────────────────────────────────┤
│ Application Layer │
│ ┌─────────────────┐ ┌──────────────────┐ ┌───────────────────────┐ │
│ │ User Interface │ │ Config Functions │ │ Persistence Manager │ │
│ │ │ │ │ │ │ │
│ │ • Input Handler │ │ • UpdateIP │ │ • Auto-save changes │ │
│ │ • Display │ │ • UpdateChooser │ │ │ │
│ └─────────────────┘ └──────────────────┘ └───────────────────────┘ │
└───────────────────────────────────────────────────────────────────────┘
void SaveConfigToStorage()
Save configuration to flash storage.
Configuration Data Flow
User Input
│
v
┌─────────────┐ Parse Command ┌───────────────────┐ Update Config ┌───────────────────┐
│ │ ────────────────> │ │ ────────────────> │ │
│ Serial │ │ Command Processor │ │ Config Parameter │
│ Console │ │ │ │ (String/IP/Int) │
│ │ <──────────────── │ │ <──────────────── │ │
└─────────────┘ Show Result └───────────────────┘ Return Status └───────────────────┘
│
v
┌───────────────────┐
│ Persistent │
│ Storage │
│ (Non-volatile) │
└───────────────────┘
Configurable Parameters
Network Settings
The application allows modification of the following network parameters:
IPv4 Static IP Address
- Command: A
- Type: IP Address (config_IPADDR4)
- Description: Device's static IP address
- Example: 192.168.1.100
IPv4 Static IP Gateway
- Command: G
- Type: IP Address (config_IPADDR4)
- Description: Network gateway address
- Example: 192.168.1.1
IPv4 Static IP Mask
- Command: M
- Type: IP Address (config_IPADDR4)
- Description: Subnet mask
- Example: 255.255.255.0
IPv4 Mode
- Command: O
- Type: Chooser (config_chooser)
- Description: IP configuration mode
- Options: Static, DHCP, AutoIP
Device Identity
Device Name
- Command: N
- Type: String (config_string)
- Description: Human-readable device identifier
- Example: "Production_Controller_01"
Discovery Settings
Discover Server URL
- Command: U
- Type: String (config_string)
- Description: Discovery server endpoint
- Example: "http://discovery.company.com/devices"
Command Interface
Available Commands
Command List
────────────
A) Show and Set IPv4 Static IP Address
C) Show Config Tree
G) Show and Set IPv4 Static IP Gateway
M) Show and Set IPv4 Static IP Mask
N) Show and Set Device Name
O) Show and Set IPv4 Mode
U) Show and Set Discover Server URL
?) Show Commands
Command Usage Flow
Application Startup
│
v
┌───────────────┐
│ Display Info │
│ • Current IP │
│ • AutoIP │
│ • Gateway │
└───────────────┘
│
v
┌───────────────┐ User Input ┌──────────────────┐
│ Wait for │ <───────────────── │ Single Character │
│ Command │ │ Command │
└───────────────┘ └──────────────────┘
│ │
v │
┌───────────────┐ │
│ Execute │ <───────────────────────────┘
│ Command │
│ Function │
└───────────────┘
│
v
┌───────────────┐
│ Save Config │
│ to Storage │
└───────────────┘
│
v
┌───────────────┐
│ Return to │
│ Command Wait │
└───────────────┘
Function Reference
Core Update Functions
UpdateConfigString(config_string &confStr)
Purpose: Updates string-based configuration parameters
- Displays current value
- Prompts for new value via serial input
- Updates configuration parameter
- Saves changes to persistent storage
UpdateConfigInt(config_int &confInt)
Purpose: Updates integer-based configuration parameters
- Displays current value
- Prompts for new numeric value
- Converts string input to integer
- Saves changes to persistent storage
UpdateConfigIpaddr(config_IPADDR4 &confIp)
Purpose: Updates IP address configuration parameters
- Displays current IP address in dotted decimal notation
- Prompts for new IP address string
- Converts string to IP address format
- Validates and saves changes
UpdateConfigChooser(config_chooser &confChooser)
Purpose: Updates chooser-based configuration parameters
- Displays current selection
- Shows available choices
- Validates user input against allowed options
- Saves valid selection
Utility Functions
ShowCommandList()
Purpose: Displays available command menu
- Lists all interactive commands
- Shows command letters and descriptions
- Called on startup and when '?' is pressed
ShowTree()
Purpose: Displays configuration tree structure
- Shows hierarchical configuration layout
- Useful for debugging and understanding config structure
- External function (implementation not shown in main.cpp)
Main Application Function
UserMain(void *pd)
Main application entry point that:
- Initializes network stack with
init()
- Enables system diagnostics
- Waits for active network connection
- Configures serial port for console interaction
- Displays initial network information
- Implements main command processing loop
Technical Implementation
Serial Console Setup
Serial Configuration:
┌──────────────────┐
│ Baud Rate: 115200│
│ Data Bits: 8 │
│ Stop Bits: 1 │
│ Parity: None │
│ Flow Control: No │
└──────────────────┘
The application reconfigures the serial port during initialization:
- Closes existing serial connection
- Reopens with 115200 baud rate
- Uses standard input/output for user interaction
Configuration Persistence
All configuration changes are automatically saved using:
This function:
- Writes changes to non-volatile storage
- Ensures persistence across device reboots
- Provides immediate effect of configuration changes
Network Interface Access
The application uses the first available network interface:
Network interface configuration block class for interface control and configuration.
Definition netinterface.h:245
int32_t GetFirstInterface(void)
Returns the Interface Number of the first registered network interface.
InterfaceBlock * GetInterfaceBlock(int interface=0)
Get an InterfaceBlock control and configuration object.
This approach:
- Automatically selects the primary network interface (typically Ethernet0)
- Provides access to all interface configuration parameters
- Works with different NetBurner hardware platforms
Usage Examples
Setting IP Address
Read char A
IPv4Address old value: 192.168.1.100
Enter new value: 192.168.1.200
IPv4Address new value: 192.168.1.200
Changing IP Mode
Read char O
IPv4Mode old value: Static
Enter
new value. Choices are {Static,
DHCP,AutoIP}:
DHCP
DHCP Namespace.
Definition dhcpd.h:39
Setting Device Name
Read char N
DeviceName old value: NetBurner_Device
Enter new value: Production_Controller
DeviceName new value: Production_Controller
Build Instructions
- Prerequisites:
- NetBurner development environment installed
- Target NetBurner hardware platform
- Serial console application (115200 baud)
- Building:
- Deployment:
make load DEVIP=<device_ip_address>
- Console Connection:
- Connect serial cable to device
- Open terminal at 115200 baud
- Reset device to see startup messages
Development Notes
Dependencies
Required NetBurner system libraries:
Build Configuration
- Application Name: SystemParamsModifyEthernet
- Source Files: src/main.cpp
- Target Platform: All NetBurner platforms
- Build System: Standard NetBurner makefile
Memory Considerations
- Configuration parameters are stored in device flash memory
- Changes are persistent across power cycles
- No additional RAM allocation required for configuration storage
- Serial input buffers are statically allocated (80 bytes for strings, 25 bytes for integers)
Error Handling
The application includes basic error handling:
- Input validation for chooser parameters
- Automatic null termination of string inputs
- Configuration save verification
- Network initialization checks
Security Considerations
Important Security Notes**:
- Serial console access provides full configuration control
- No authentication mechanism implemented
- Consider adding access control for production environments
- Configuration changes take effect immediately without confirmation
Compatibility
- Compatible with all NetBurner embedded platforms
- Requires NetBurner RTOS version 3.x or later
- Works with Ethernet and Wi-Fi interfaces
- Supports IPv4 configuration (IPv6 not included in this example)